@oxy.so/core 7.13.0 → 7.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FollowsApi = void 0;
4
4
  const apiUtils_1 = require("../utils/apiUtils");
5
- const enc = encodeURIComponent;
5
+ const identityCacheSweep_1 = require("../utils/identityCacheSweep");
6
6
  const GRAPH_TTL = 2 * 60 * 1000;
7
7
  const STATUS_TTL = 60 * 1000;
8
8
  /**
@@ -17,7 +17,7 @@ class FollowsApi {
17
17
  // ── People ───────────────────────────────────────────────────────────────
18
18
  /** Follow a user. */
19
19
  async follow(userId) {
20
- const result = await this.ctx.request('POST', `/users/${enc(userId)}/follow`, undefined, { cache: false });
20
+ const result = await this.ctx.request('POST', `${(0, identityCacheSweep_1.oxyUserByIdPath)(userId)}/follow`, undefined, { cache: false });
21
21
  this.invalidate([userId]);
22
22
  return result;
23
23
  }
@@ -31,7 +31,7 @@ class FollowsApi {
31
31
  }
32
32
  /** Unfollow a user. */
33
33
  async unfollow(userId) {
34
- const result = await this.ctx.request('DELETE', `/users/${enc(userId)}/follow`, undefined, { cache: false });
34
+ const result = await this.ctx.request('DELETE', `${(0, identityCacheSweep_1.oxyUserByIdPath)(userId)}/follow`, undefined, { cache: false });
35
35
  this.invalidate([userId]);
36
36
  return result;
37
37
  }
@@ -45,7 +45,7 @@ class FollowsApi {
45
45
  }
46
46
  /** Whether the signed-in user follows `userId`. Cached 1 minute, busted by every write. */
47
47
  async status(userId) {
48
- return this.ctx.request('GET', `/users/${enc(userId)}/follow-status`, undefined, {
48
+ return this.ctx.request('GET', `${(0, identityCacheSweep_1.oxyUserByIdPath)(userId)}/follow-status`, undefined, {
49
49
  cache: true,
50
50
  cacheTTL: STATUS_TTL,
51
51
  });
@@ -75,12 +75,12 @@ class FollowsApi {
75
75
  * `limit`/`offset`/`sort` combination is its own cache entry (2 minutes).
76
76
  */
77
77
  async followers(userId, params) {
78
- const { data, total, hasMore } = await this.userPage(`/users/${enc(userId)}/followers`, params);
78
+ const { data, total, hasMore } = await this.userPage(`${(0, identityCacheSweep_1.oxyUserByIdPath)(userId)}/followers`, params);
79
79
  return { followers: data, total, hasMore };
80
80
  }
81
81
  /** Who a user follows. `sort` as in `followers`. */
82
82
  async following(userId, params) {
83
- const { data, total, hasMore } = await this.userPage(`/users/${enc(userId)}/following`, params);
83
+ const { data, total, hasMore } = await this.userPage(`${(0, identityCacheSweep_1.oxyUserByIdPath)(userId)}/following`, params);
84
84
  return { following: data, total, hasMore };
85
85
  }
86
86
  /**
@@ -88,7 +88,7 @@ class FollowsApi {
88
88
  * `userId`.
89
89
  */
90
90
  async mutuals(userId, params) {
91
- const { data, total, hasMore } = await this.userPage(`/users/${enc(userId)}/mutuals`, params);
91
+ const { data, total, hasMore } = await this.userPage(`${(0, identityCacheSweep_1.oxyUserByIdPath)(userId)}/mutuals`, params);
92
92
  return { mutuals: data, total, hasMore };
93
93
  }
94
94
  /**
@@ -223,16 +223,17 @@ class FollowsApi {
223
223
  const keys = ['GET:/users/me/graph'];
224
224
  const prefixes = ['GET:/profiles/username/', 'GET:/profiles/resolve'];
225
225
  for (const id of targetUserIds) {
226
- keys.push(`GET:/users/${enc(id)}/follow-status`);
226
+ const user = (0, identityCacheSweep_1.oxyUserByIdPath)(id);
227
+ keys.push(`GET:${user}/follow-status`);
227
228
  // Profiles embed the viewer-relative `relationship`.
228
- keys.push(`GET:/users/${enc(id)}`);
229
+ keys.push((0, identityCacheSweep_1.oxyUserByIdCacheKey)(id));
229
230
  // The target gained or lost a follower, and "followers you know" with it.
230
- prefixes.push(`GET:/users/${enc(id)}/followers`, `GET:/users/${enc(id)}/mutuals`);
231
+ prefixes.push(`GET:${user}/followers`, `GET:${user}/mutuals`);
231
232
  }
232
233
  // The viewer's own following list changed.
233
234
  const viewerId = this.ctx.oxy.session.userId;
234
235
  if (viewerId)
235
- prefixes.push(`GET:/users/${enc(viewerId)}/following`);
236
+ prefixes.push(`GET:${(0, identityCacheSweep_1.oxyUserByIdPath)(viewerId)}/following`);
236
237
  this.ctx.http.invalidateCache({ keys, prefixes });
237
238
  }
238
239
  }
@@ -62,7 +62,7 @@ class UsersApi {
62
62
  * registry-fresh read that neither serves nor overwrites a cached entry.
63
63
  */
64
64
  async get(userId, options) {
65
- const user = await this.ctx.request('GET', `/users/${enc(userId)}`, undefined, {
65
+ const user = await this.ctx.request('GET', (0, identityCacheSweep_1.oxyUserByIdPath)(userId), undefined, {
66
66
  cache: options?.cache ?? true,
67
67
  cacheTTL: PROFILE_TTL,
68
68
  });