@openpeepshq/core 0.12.0 → 0.14.0

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.
@@ -136,6 +136,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
136
136
  speakers?: string[] | undefined;
137
137
  presenters?: string[] | undefined;
138
138
  audience?: string[] | undefined;
139
+ banned?: string[] | undefined;
139
140
  maxSpeakers?: number | undefined;
140
141
  maxPresenters?: number | undefined;
141
142
  maxAudience?: number | undefined;
@@ -371,6 +372,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
371
372
  speakers?: string[] | undefined;
372
373
  presenters?: string[] | undefined;
373
374
  audience?: string[] | undefined;
375
+ banned?: string[] | undefined;
374
376
  maxSpeakers?: number | undefined;
375
377
  maxPresenters?: number | undefined;
376
378
  maxAudience?: number | undefined;
@@ -636,6 +638,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
636
638
  speakers?: string[] | undefined;
637
639
  presenters?: string[] | undefined;
638
640
  audience?: string[] | undefined;
641
+ banned?: string[] | undefined;
639
642
  maxSpeakers?: number | undefined;
640
643
  maxPresenters?: number | undefined;
641
644
  maxAudience?: number | undefined;
@@ -871,6 +874,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
871
874
  speakers?: string[] | undefined;
872
875
  presenters?: string[] | undefined;
873
876
  audience?: string[] | undefined;
877
+ banned?: string[] | undefined;
874
878
  maxSpeakers?: number | undefined;
875
879
  maxPresenters?: number | undefined;
876
880
  maxAudience?: number | undefined;
@@ -92,13 +92,19 @@ export const transformPost = async (post, currentProfile, options = {}) => {
92
92
  ? await Promise.all(post.entries.map(addProfileForEntry))
93
93
  : [];
94
94
  const entries = allEntries.filter((entry) => !isReactionHistoryEntry(entry.type));
95
- // The public schema only accepts curated reactions, so drop anything else
96
- // (legacy logs) before it can fail response validation.
95
+ // Legacy logs can carry malformed/empty reactions, so drop anything
96
+ // unusable before it can fail response validation. Reactions attached
97
+ // before a community removed them from its configured set (orphans) are
98
+ // intentionally kept — only new reactions are constrained by the write path.
97
99
  const reactions = currentReactionsFromEntries(allEntries)
98
100
  .filter((item) => isReactionType(item.reaction))
99
101
  // Privacy boundary: hide reactions from blocked pairs (either direction),
100
102
  // mirroring how blocked creators are tombstoned via withBlockTombstone.
101
- .filter((item) => !currentProfile || !isBlockedPair(currentProfile, item.profile.id));
103
+ .filter((item) => !currentProfile || !isBlockedPair(currentProfile, item.profile.id))
104
+ .map((item) => ({
105
+ reaction: item.reaction,
106
+ profile: item.profile,
107
+ }));
102
108
  const reposts = await leanRepostsFromWrappers(post.reposts);
103
109
  const audience = post.audience
104
110
  ? (await Promise.all(post.audience.map((p) => loadPublicProfile(p.id)))).filter((profile) => !!profile)
@@ -136,6 +136,7 @@ export declare const threadPreviewMappingForProfile: (profile?: {
136
136
  speakers?: string[] | undefined;
137
137
  presenters?: string[] | undefined;
138
138
  audience?: string[] | undefined;
139
+ banned?: string[] | undefined;
139
140
  maxSpeakers?: number | undefined;
140
141
  maxPresenters?: number | undefined;
141
142
  maxAudience?: number | undefined;
@@ -383,6 +384,7 @@ export declare const postsWithReplyCountMapping: Mapping<{
383
384
  speakers?: string[] | undefined;
384
385
  presenters?: string[] | undefined;
385
386
  audience?: string[] | undefined;
387
+ banned?: string[] | undefined;
386
388
  maxSpeakers?: number | undefined;
387
389
  maxPresenters?: number | undefined;
388
390
  maxAudience?: number | undefined;
@@ -625,6 +627,7 @@ export declare const postsWithReplyCountMapping: Mapping<{
625
627
  speakers?: string[] | undefined;
626
628
  presenters?: string[] | undefined;
627
629
  audience?: string[] | undefined;
630
+ banned?: string[] | undefined;
628
631
  maxSpeakers?: number | undefined;
629
632
  maxPresenters?: number | undefined;
630
633
  maxAudience?: number | undefined;
@@ -871,6 +874,7 @@ export declare const postsWithReplyCountMapping: Mapping<{
871
874
  speakers?: string[] | undefined;
872
875
  presenters?: string[] | undefined;
873
876
  audience?: string[] | undefined;
877
+ banned?: string[] | undefined;
874
878
  maxSpeakers?: number | undefined;
875
879
  maxPresenters?: number | undefined;
876
880
  maxAudience?: number | undefined;
@@ -1114,6 +1118,7 @@ export declare const postsWithReplyToCountMapping: Mapping<{
1114
1118
  speakers?: string[] | undefined;
1115
1119
  presenters?: string[] | undefined;
1116
1120
  audience?: string[] | undefined;
1121
+ banned?: string[] | undefined;
1117
1122
  maxSpeakers?: number | undefined;
1118
1123
  maxPresenters?: number | undefined;
1119
1124
  maxAudience?: number | undefined;
@@ -1356,6 +1361,7 @@ export declare const postsWithReplyToCountMapping: Mapping<{
1356
1361
  speakers?: string[] | undefined;
1357
1362
  presenters?: string[] | undefined;
1358
1363
  audience?: string[] | undefined;
1364
+ banned?: string[] | undefined;
1359
1365
  maxSpeakers?: number | undefined;
1360
1366
  maxPresenters?: number | undefined;
1361
1367
  maxAudience?: number | undefined;
@@ -1602,6 +1608,7 @@ export declare const postsWithReplyToCountMapping: Mapping<{
1602
1608
  speakers?: string[] | undefined;
1603
1609
  presenters?: string[] | undefined;
1604
1610
  audience?: string[] | undefined;
1611
+ banned?: string[] | undefined;
1605
1612
  maxSpeakers?: number | undefined;
1606
1613
  maxPresenters?: number | undefined;
1607
1614
  maxAudience?: number | undefined;
@@ -1845,6 +1852,7 @@ export declare const postsMapping: Mapping<{
1845
1852
  speakers?: string[] | undefined;
1846
1853
  presenters?: string[] | undefined;
1847
1854
  audience?: string[] | undefined;
1855
+ banned?: string[] | undefined;
1848
1856
  maxSpeakers?: number | undefined;
1849
1857
  maxPresenters?: number | undefined;
1850
1858
  maxAudience?: number | undefined;
@@ -2085,6 +2093,7 @@ export declare const postsAuthMapping: Mapping<{
2085
2093
  speakers?: string[] | undefined;
2086
2094
  presenters?: string[] | undefined;
2087
2095
  audience?: string[] | undefined;
2096
+ banned?: string[] | undefined;
2088
2097
  maxSpeakers?: number | undefined;
2089
2098
  maxPresenters?: number | undefined;
2090
2099
  maxAudience?: number | undefined;
@@ -2326,6 +2335,7 @@ export declare const postsMappingForProfile: (profile?: {
2326
2335
  speakers?: string[] | undefined;
2327
2336
  presenters?: string[] | undefined;
2328
2337
  audience?: string[] | undefined;
2338
+ banned?: string[] | undefined;
2329
2339
  maxSpeakers?: number | undefined;
2330
2340
  maxPresenters?: number | undefined;
2331
2341
  maxAudience?: number | undefined;
@@ -2567,6 +2577,7 @@ export declare const postContextMappingForProfile: (profile?: {
2567
2577
  speakers?: string[] | undefined;
2568
2578
  presenters?: string[] | undefined;
2569
2579
  audience?: string[] | undefined;
2580
+ banned?: string[] | undefined;
2570
2581
  maxSpeakers?: number | undefined;
2571
2582
  maxPresenters?: number | undefined;
2572
2583
  maxAudience?: number | undefined;
@@ -2807,6 +2818,7 @@ export declare const conversationLeavesMapping: Mapping<{
2807
2818
  speakers?: string[] | undefined;
2808
2819
  presenters?: string[] | undefined;
2809
2820
  audience?: string[] | undefined;
2821
+ banned?: string[] | undefined;
2810
2822
  maxSpeakers?: number | undefined;
2811
2823
  maxPresenters?: number | undefined;
2812
2824
  maxAudience?: number | undefined;
@@ -3048,6 +3060,7 @@ export declare const conversationLeavesMappingForProfile: (profile?: {
3048
3060
  speakers?: string[] | undefined;
3049
3061
  presenters?: string[] | undefined;
3050
3062
  audience?: string[] | undefined;
3063
+ banned?: string[] | undefined;
3051
3064
  maxSpeakers?: number | undefined;
3052
3065
  maxPresenters?: number | undefined;
3053
3066
  maxAudience?: number | undefined;
@@ -3287,6 +3300,7 @@ export declare const postIdsMapping: Mapping<{
3287
3300
  speakers?: string[] | undefined;
3288
3301
  presenters?: string[] | undefined;
3289
3302
  audience?: string[] | undefined;
3303
+ banned?: string[] | undefined;
3290
3304
  maxSpeakers?: number | undefined;
3291
3305
  maxPresenters?: number | undefined;
3292
3306
  maxAudience?: number | undefined;
@@ -137,6 +137,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile, dat
137
137
  speakers?: string[] | undefined;
138
138
  presenters?: string[] | undefined;
139
139
  audience?: string[] | undefined;
140
+ banned?: string[] | undefined;
140
141
  maxSpeakers?: number | undefined;
141
142
  maxPresenters?: number | undefined;
142
143
  maxAudience?: number | undefined;
@@ -372,6 +373,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile, dat
372
373
  speakers?: string[] | undefined;
373
374
  presenters?: string[] | undefined;
374
375
  audience?: string[] | undefined;
376
+ banned?: string[] | undefined;
375
377
  maxSpeakers?: number | undefined;
376
378
  maxPresenters?: number | undefined;
377
379
  maxAudience?: number | undefined;
@@ -169,13 +169,23 @@ export const updatePost = async (post, profile, data) => {
169
169
  hub.emit('postUpdated', newPost, previousEvent?.jam?.moderators ?? []);
170
170
  return newPost;
171
171
  };
172
- export const reactToPost = async (post, profile, data) => allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
173
- type: 'reaction',
174
- data: { reaction: data.reaction },
175
- }).then(() => hub.emit('reactionCreated', profile, post, {
176
- type: 'reaction',
177
- ...data,
178
- })));
172
+ export const reactToPost = async (post, profile, data) => {
173
+ // Idempotency: one reaction per emoji per profile. Tapping the same emoji
174
+ // twice (a second tab, a stale client, a client retry) must be a no-op —
175
+ // otherwise the entry is stored twice and each row fires `reactionCreated`,
176
+ // so the author gets a duplicate notification per extra tap. `post.reactions`
177
+ // is the latest-entry-per-(profile, emoji) view, already deduplicated.
178
+ const alreadyReacted = post.reactions.some((reaction) => reaction.profile.id === profile.id && reaction.reaction === data.reaction);
179
+ if (alreadyReacted)
180
+ return;
181
+ return allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
182
+ type: 'reaction',
183
+ data: { reaction: data.reaction },
184
+ }).then(() => hub.emit('reactionCreated', profile, post, {
185
+ type: 'reaction',
186
+ ...data,
187
+ })));
188
+ };
179
189
  export const retractReaction = async (post, profile, data) => allpeepDb().then(({ db }) => entryConnector(db, profile, post, {
180
190
  type: 'unreaction',
181
191
  data: { reaction: data.reaction },
@@ -1,7 +1,9 @@
1
- import { communityConfig } from '../config/index.js';
1
+ import { communityConfigFresh } from '../config/index.js';
2
+ import { logger } from '../log/index.js';
2
3
  import { hub } from '../events/index.js';
3
4
  import { getProfile } from './cache.js';
4
5
  import { followDesignatedProfiles } from './mutations.js';
6
+ const log = logger('app:profiles:autoFollow');
5
7
  const handleProfileCreated = async (profileArg) => {
6
8
  const profile = profileArg;
7
9
  if (!profile?.id)
@@ -11,10 +13,26 @@ const handleProfileCreated = async (profileArg) => {
11
13
  const fresh = await getProfile(profile.id);
12
14
  if (!fresh)
13
15
  return;
14
- const autoFollow = (await communityConfig()).content.autoFollow;
15
- if (!autoFollow?.length)
16
- return;
17
- await followDesignatedProfiles(fresh, autoFollow);
16
+ // Read the community config fresh from the DB rather than through the
17
+ // in-memory cache: this handler runs in the worker process, whose cache is
18
+ // only refreshed on a redis pub/sub `configUpdated` event that a worker
19
+ // connection can miss. A stale cache left empty/old `content.autoFollow`
20
+ // would silently skip the designated follows after an admin saved them.
21
+ try {
22
+ const autoFollow = (await communityConfigFresh()).content.autoFollow;
23
+ if (!autoFollow?.length)
24
+ return;
25
+ await followDesignatedProfiles(fresh, autoFollow);
26
+ }
27
+ catch (error) {
28
+ // Re-throw so the once-queue job fails; it stays retained for diagnosis
29
+ // (30-day removeOnFail age) with its failedReason — the queue sets no
30
+ // attempts, so no retry is scheduled. The worker's last-five-errors table
31
+ // prints only the raw failedReason (no profile id), so the handler-level
32
+ // log line is what makes the failed profile identifiable.
33
+ log.error(`auto-follow handler failed for profile ${profile.id}`, error);
34
+ throw error;
35
+ }
18
36
  };
19
37
  let registered = false;
20
38
  /** Subscribes the designated-account follows to profileCreated (once queue). */
@@ -68,6 +68,7 @@ export declare const serverInfo: () => Promise<{
68
68
  welcomeEmail?: string | undefined;
69
69
  pinnedPost?: string | undefined;
70
70
  autoFollow?: string[] | undefined;
71
+ allowedReactions?: string[] | undefined;
71
72
  };
72
73
  settings: {
73
74
  openRegistrations: boolean;
@@ -128,6 +128,7 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
128
128
  speakers?: string[] | undefined;
129
129
  presenters?: string[] | undefined;
130
130
  audience?: string[] | undefined;
131
+ banned?: string[] | undefined;
131
132
  maxSpeakers?: number | undefined;
132
133
  maxPresenters?: number | undefined;
133
134
  maxAudience?: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/core",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "dependencies": {
@@ -8,7 +8,7 @@
8
8
  "@keyv/redis": "^5.1.4",
9
9
  "@sentry/node": "^10.78.0",
10
10
  "apns2": "^12.2.0",
11
- "archiver": "^7.0.1",
11
+ "archiver": "^8.0.0",
12
12
  "bcrypt": "^5.1.1",
13
13
  "bullmq": "^5.81.5",
14
14
  "cache-manager": "^7.2.4",
@@ -18,7 +18,7 @@
18
18
  "deepmerge-ts": "^8.0.2",
19
19
  "dotenv": "^16.4.7",
20
20
  "drizzle-orm": "^0.45.2",
21
- "firebase-admin": "^13.10.0",
21
+ "firebase-admin": "^14.5.1",
22
22
  "fluent-ffmpeg": "^2.1.3",
23
23
  "fs-extra": "^11.3.0",
24
24
  "html-to-text": "^9.0.5",
@@ -37,10 +37,10 @@
37
37
  "type-fest": "^4.31.0",
38
38
  "uuidv7": "^1.0.2",
39
39
  "web-push": "^3.6.7",
40
- "@openpeepshq/common": "0.13.0",
41
- "@openpeepshq/geocoder": "^0.1.2",
40
+ "@openpeepshq/common": "0.15.0",
42
41
  "@openpeepshq/fetch-client": "^0.2.1",
43
- "@openpeepshq/i18n": "^0.14.0"
42
+ "@openpeepshq/geocoder": "^0.1.2",
43
+ "@openpeepshq/i18n": "^0.16.0"
44
44
  },
45
45
  "main": "dist/index.js",
46
46
  "types": "dist/index.d.ts",
@@ -52,7 +52,7 @@
52
52
  "/dist"
53
53
  ],
54
54
  "devDependencies": {
55
- "@types/archiver": "^6.0.3",
55
+ "@types/archiver": "^8.0.0",
56
56
  "@types/bcrypt": "^5.0.2",
57
57
  "@types/express": "^5.0.6",
58
58
  "@types/fluent-ffmpeg": "^2.1.27",