@openpeepshq/core 0.12.0 → 0.13.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.
@@ -4,7 +4,7 @@ import { spawn } from 'node:child_process';
4
4
  import { emptyDir } from 'fs-extra';
5
5
  import { join, sep, isAbsolute } from 'node:path';
6
6
  import { tmpdir } from 'node:os';
7
- import archiver from 'archiver';
7
+ import { ZipArchive } from 'archiver';
8
8
  import { extractWithNodeStreamZip } from './extractWithNodeStreamZip.js';
9
9
  import { collectionInfos } from '../db/index.js';
10
10
  import { communityConfig, config, defaultConfig } from '../config/index.js';
@@ -96,7 +96,7 @@ const hostnameFromServerHost = (host) => {
96
96
  };
97
97
  const zipDirectory = (sourceDir, zipPath) => new Promise((resolve, reject) => {
98
98
  const output = createWriteStream(zipPath);
99
- const archive = archiver('zip', { zlib: { level: 9 } });
99
+ const archive = new ZipArchive({ zlib: { level: 9 } });
100
100
  output.on('close', () => resolve());
101
101
  output.on('error', reject);
102
102
  archive.on('error', reject);
@@ -67,6 +67,7 @@ export declare const communityConfig: () => Promise<{
67
67
  welcomeEmail?: string | undefined;
68
68
  pinnedPost?: string | undefined;
69
69
  autoFollow?: string[] | undefined;
70
+ allowedReactions?: string[] | undefined;
70
71
  };
71
72
  settings: {
72
73
  openRegistrations: boolean;
@@ -1,4 +1,4 @@
1
- import { type AuthorizationData, type MuteParticipantRequest, type PostWithMeta, type Profile } from '@openpeepshq/common/types';
1
+ import type { AuthorizationData, MuteParticipantRequest, PostWithMeta, Profile } from '@openpeepshq/common/types';
2
2
  export { createJamToken, createJamEgressToken } from './token';
3
3
  export { diagnoseLivekit, isLivekitConnected } from './health';
4
4
  export { startRecording, stopRecording, startRtmpStream, stopRtmpStream, stopEgress, listParticipantIds, reclaimOrphanJamRoom, finishRecording, getJamRecordingUrl, getJamObserverPath, JAM_ROOM_EMPTY_TIMEOUT_SEC, JAM_ROOM_DEPARTURE_TIMEOUT_SEC, } from './livekit';
@@ -16,3 +16,16 @@ export declare const closeJam: (profile: Profile, jamEvent: PostWithMeta, recurr
16
16
  export declare const muteParticipant: (jamId: string, data: MuteParticipantRequest, recurrenceId?: string) => Promise<{
17
17
  success: boolean;
18
18
  }>;
19
+ /**
20
+ * Bans a removed profile from rejoining, evicts them now, and records the kick.
21
+ *
22
+ * (a) The ban persist happens before the eviction on purpose: the eviction is
23
+ * best-effort (its failure is swallowed below), but the ban is not — the
24
+ * profile must be locked out even if LiveKit is unreachable.
25
+ * (b) An already-banned target skips only the persist: the waiting-room
26
+ * admittance clear, the eviction attempt, and the `kicked` record still run,
27
+ * so a pending admittee is not left stranded.
28
+ */
29
+ export declare const removeParticipant: (jamEvent: PostWithMeta, profileId: string, recurrenceId?: string) => Promise<void>;
30
+ /** Lifts a ban; the profile simply becomes able to rejoin again. */
31
+ export declare const liftJamBan: (jamEvent: PostWithMeta, profileId: string) => Promise<void>;
@@ -1,10 +1,13 @@
1
- import { jamRoomName, postIdFromJamRoomName, uniquePostsById, } from '@openpeepshq/common/lib';
1
+ import { jamFromEvent, jamRoomName, postIdFromJamRoomName, uniquePostsById, } from '@openpeepshq/common/lib';
2
2
  import { listParticipantIds, reclaimOrphanJamRoom, roomService, shouldReclaimJamRoom, stopRecording, stopRtmpStream, } from './livekit.js';
3
3
  import { jamStateCache, LIVE_JAMS_CACHE_KEY, liveJamPostsCache } from './cache.js';
4
4
  import { localInstanceDomain, parseRoomInstanceDomain } from './helpers.js';
5
5
  import { findPost } from '../posts/index.js';
6
+ import { allpeepDb } from '../db/index.js';
6
7
  import { createJamEvent } from './mutations.js';
8
+ import { postsMapping } from '../posts/mapping.js';
7
9
  import { clearJamAdmittance } from './waitingRoom.js';
10
+ import { hub } from '../events/index.js';
8
11
  import { uuidv7 } from 'uuidv7';
9
12
  import { canReadPost } from '../posts/helpers/index.js';
10
13
  import { capabilitiesConfig } from '../config/index.js';
@@ -27,6 +30,29 @@ const invalidateJamCaches = async (jamId) => {
27
30
  liveJamPostsCache.del(LIVE_JAMS_CACHE_KEY).catch(() => undefined),
28
31
  ]);
29
32
  };
33
+ /**
34
+ * Shared persist-and-notify step for the two jam-config ban mutations
35
+ * ({@link removeParticipant} and {@link liftJamBan}): writes the jam's new
36
+ * `banned` list to the post, invalidates the live-jam caches, and re-broadcasts
37
+ * the fresh post to the moderators. Both paths must keep doing all three —
38
+ * dropping the cache invalidation here would be the drift this exists to
39
+ * prevent.
40
+ */
41
+ const persistJamBannedList = async (jamEvent, jam, banned) => {
42
+ const { db } = await allpeepDb();
43
+ await postsMapping.update(db, jamEvent.id, {
44
+ data: {
45
+ ...jamEvent.data,
46
+ type: 'event',
47
+ jam: { ...jam, banned },
48
+ },
49
+ });
50
+ const freshPost = await findPost(jamEvent.id);
51
+ await invalidateJamCaches(jamEvent.id);
52
+ if (freshPost) {
53
+ await hub.emit('postUpdated', freshPost, jam.moderators);
54
+ }
55
+ };
30
56
  const reclaimLocalOrphan = (post) => {
31
57
  void reclaimOrphanJamRoom(post).then(() => invalidateJamCaches(post.id));
32
58
  };
@@ -131,3 +157,51 @@ export const muteParticipant = async (jamId, data, recurrenceId) => {
131
157
  }
132
158
  return { success: result?.muted };
133
159
  };
160
+ /**
161
+ * Bans a removed profile from rejoining, evicts them now, and records the kick.
162
+ *
163
+ * (a) The ban persist happens before the eviction on purpose: the eviction is
164
+ * best-effort (its failure is swallowed below), but the ban is not — the
165
+ * profile must be locked out even if LiveKit is unreachable.
166
+ * (b) An already-banned target skips only the persist: the waiting-room
167
+ * admittance clear, the eviction attempt, and the `kicked` record still run,
168
+ * so a pending admittee is not left stranded.
169
+ */
170
+ export const removeParticipant = async (jamEvent, profileId, recurrenceId) => {
171
+ const jam = jamFromEvent(jamEvent);
172
+ if (jam && !jam.banned?.includes(profileId)) {
173
+ await persistJamBannedList(jamEvent, jam, [
174
+ ...(jam.banned ?? []),
175
+ profileId,
176
+ ]);
177
+ }
178
+ await clearJamAdmittance(jamEvent, recurrenceId, [profileId]);
179
+ const rs = await roomService();
180
+ if (rs !== undefined) {
181
+ try {
182
+ // LiveKit disconnects the participant with reason PARTICIPANT_REMOVED,
183
+ // which the client uses to show the removed-from-jam state.
184
+ await rs.removeParticipant(jamRoomName(jamEvent.id, recurrenceId), profileId);
185
+ }
186
+ catch (err) {
187
+ // The participant may already have left the room; the ban persists.
188
+ log.debug(err, 'removeParticipant: LiveKit removal failed');
189
+ }
190
+ }
191
+ await createJamEvent({
192
+ id: uuidv7(),
193
+ jamId: jamEvent.id,
194
+ type: 'kicked',
195
+ profileId,
196
+ recurrenceId,
197
+ });
198
+ };
199
+ /** Lifts a ban; the profile simply becomes able to rejoin again. */
200
+ export const liftJamBan = async (jamEvent, profileId) => {
201
+ const jam = jamFromEvent(jamEvent);
202
+ if (!jam?.banned?.includes(profileId)) {
203
+ return;
204
+ }
205
+ const banned = jam.banned.filter((id) => id !== profileId);
206
+ await persistJamBannedList(jamEvent, jam, banned);
207
+ };
@@ -7,37 +7,37 @@ type EdgeMetadata = {
7
7
  export declare const jamEventsMapping: import("../db/pg/map").Mapping<{
8
8
  id: string;
9
9
  jamId: string;
10
- type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
10
+ type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "kicked" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
11
11
  profileId: string;
12
12
  content?: string | undefined;
13
- reaction?: "👍" | "👎" | "❤️" | "😂" | "😮" | "😢" | "🎉" | undefined;
13
+ reaction?: string | undefined;
14
14
  recurrenceId?: string | undefined;
15
15
  }, JamEvent, JamEvent>;
16
16
  export declare const jamSessionStartsMapping: import("../db/pg/map").Mapping<{
17
17
  id: string;
18
18
  jamId: string;
19
- type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
19
+ type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "kicked" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
20
20
  profileId: string;
21
21
  content?: string | undefined;
22
- reaction?: "👍" | "👎" | "❤️" | "😂" | "😮" | "😢" | "🎉" | undefined;
22
+ reaction?: string | undefined;
23
23
  recurrenceId?: string | undefined;
24
24
  }, JamEvent, JamEvent>;
25
25
  export declare const jamSessionClosesMapping: import("../db/pg/map").Mapping<{
26
26
  id: string;
27
27
  jamId: string;
28
- type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
28
+ type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "kicked" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
29
29
  profileId: string;
30
30
  content?: string | undefined;
31
- reaction?: "👍" | "👎" | "❤️" | "😂" | "😮" | "😢" | "🎉" | undefined;
31
+ reaction?: string | undefined;
32
32
  recurrenceId?: string | undefined;
33
33
  }, JamEvent, JamEvent>;
34
34
  export declare const jamParticipantsMapping: import("../db/pg/map").Mapping<{
35
35
  id: string;
36
36
  jamId: string;
37
- type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
37
+ type: "message" | "join" | "close" | "reaction" | "start" | "leave" | "kicked" | "recordStart" | "recordStop" | "streamStart" | "streamStop";
38
38
  profileId: string;
39
39
  content?: string | undefined;
40
- reaction?: "👍" | "👎" | "❤️" | "😂" | "😮" | "😢" | "🎉" | undefined;
40
+ reaction?: string | undefined;
41
41
  recurrenceId?: string | undefined;
42
42
  }, JamEvent, JamEvent>;
43
43
  export declare const jamRecordingRelation: RelationWithMapping<PostWithMeta, JamRecording>;
@@ -71,6 +71,9 @@ export const createJamToken = async (event, profile, { external = false, recurre
71
71
  if (joiner && isBlockedPair(joiner, event.profile?.id)) {
72
72
  throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
73
73
  }
74
+ if (jam?.banned?.includes(profile.id)) {
75
+ throw forbidden({ errorKey: 'error.jamBanned' });
76
+ }
74
77
  assertJamRsvpAllowed(event, profile, recurrenceId);
75
78
  const rs = await roomService();
76
79
  if (rs === undefined) {
@@ -1,6 +1,6 @@
1
1
  import { type JamWaitingRoomEntry, type PublicProfile, type PostWithMeta } from '@openpeepshq/common/types';
2
2
  export declare const isAdmittedToJam: (event: PostWithMeta, profileId: string, recurrenceId?: string) => Promise<boolean>;
3
- export declare const clearJamAdmittance: (event: PostWithMeta, recurrenceId?: string) => Promise<void>;
3
+ export declare const clearJamAdmittance: (event: PostWithMeta, recurrenceId?: string, onlyProfileIds?: string[]) => Promise<void>;
4
4
  export declare const currentWaitingRoomWatch: (jamEvent: PostWithMeta, onChange: (waitingRoom: Record<string, JamWaitingRoomEntry>) => void | Promise<void>, recurrenceId?: string) => Promise<() => Promise<void>>;
5
5
  export declare const admittanceWatch: (jamEvent: PostWithMeta, profileId: string, onToken: (token: string) => Promise<void> | void, recurrenceId?: string) => Promise<() => Promise<void>>;
6
6
  export declare const joinWaitingRoom: (event: PostWithMeta, profile: PublicProfile, recurrenceId?: string) => Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { jamRoomName } from '@openpeepshq/common/lib';
2
2
  import { jamWaitingRoomEntrySchema, } from '@openpeepshq/common/types';
3
+ import { forbidden } from '../errors/index.js';
3
4
  import { assertJamRsvpAllowed, createJamToken } from './token.js';
4
5
  import { disconnect, getConnection, getSharedConnection, } from '../redis/connection.js';
5
6
  import { getProfile } from '../profiles/index.js';
@@ -18,7 +19,17 @@ export const isAdmittedToJam = async (event, profileId, recurrenceId) => {
18
19
  const conn = await getSharedConnection();
19
20
  return Boolean(await conn.hExists(admittanceKey(event, recurrenceId), profileId));
20
21
  };
21
- export const clearJamAdmittance = async (event, recurrenceId) => {
22
+ export const clearJamAdmittance = async (event, recurrenceId, onlyProfileIds) => {
23
+ if (onlyProfileIds !== undefined) {
24
+ // Per-profile path: an explicit (possibly empty) id set must never fall
25
+ // through to the wipe-everything del() below, so `[]` is a no-op.
26
+ if (onlyProfileIds.length === 0)
27
+ return;
28
+ await getSharedConnection().then((conn) =>
29
+ // ioredis flattens an array field at the protocol level.
30
+ conn.hDel(admittanceKey(event, recurrenceId), onlyProfileIds));
31
+ return;
32
+ }
22
33
  await getSharedConnection().then((conn) => conn.del(admittanceKey(event, recurrenceId)));
23
34
  };
24
35
  export const currentWaitingRoomWatch = (jamEvent, onChange, recurrenceId) => currentWaitingRoom(jamEvent, recurrenceId)
@@ -53,6 +64,13 @@ export const admittanceWatch = (jamEvent, profileId, onToken, recurrenceId) => c
53
64
  await disconnect(conn);
54
65
  }));
55
66
  export const joinWaitingRoom = async (event, profile, recurrenceId) => {
67
+ // A removed (banned) profile must not be able to queue at all — mirroring
68
+ // the `createJamToken` gate, so the refusal happens up front instead of at
69
+ // the moderator's later "admit" click.
70
+ const jam = event.data?.type === 'event' ? event.data?.jam : undefined;
71
+ if (jam?.banned?.includes(profile.id)) {
72
+ throw forbidden({ errorKey: 'error.jamBanned' });
73
+ }
56
74
  assertJamRsvpAllowed(event, profile, recurrenceId);
57
75
  const conn = await getSharedConnection();
58
76
  const wrKey = waitingRoomKey(event, recurrenceId);
@@ -1,7 +1,7 @@
1
1
  import { createReadStream, createWriteStream } from 'node:fs';
2
2
  import { readdir, rm, stat } from 'node:fs/promises';
3
3
  import { basename, join } from 'node:path';
4
- import archiver from 'archiver';
4
+ import { ZipArchive } from 'archiver';
5
5
  const DAY_MS = 24 * 60 * 60 * 1000;
6
6
  /** Daily log file as written by the logger, e.g. `20261001.log`. */
7
7
  const RAW_LOG_FILE = /^\d{8}\.log$/;
@@ -18,7 +18,7 @@ const fileExists = async (path) => {
18
18
  };
19
19
  const zipLogFile = (file, zipPath) => new Promise((resolve, reject) => {
20
20
  const output = createWriteStream(zipPath);
21
- const archive = archiver('zip', { zlib: { level: 9 } });
21
+ const archive = new ZipArchive({ zlib: { level: 9 } });
22
22
  output.on('close', () => resolve());
23
23
  output.on('error', reject);
24
24
  archive.on('error', reject);
@@ -6,7 +6,8 @@ import { logFailure, logStep } from '../jobs/index.js';
6
6
  import { deletePushSubscription, listPushSubscriptionsByAccount, } from '../pushSubscriptions/index.js';
7
7
  import { getNotificationStats } from './finders.js';
8
8
  import { ApnsClient, Notification as IOSPushNotification } from 'apns2';
9
- import firebase from 'firebase-admin';
9
+ import { getApps } from 'firebase-admin/app';
10
+ import { getMessaging } from 'firebase-admin/messaging';
10
11
  import { jwtUtil } from '../jwt/index.js';
11
12
  import { uuidv7 } from 'uuidv7';
12
13
  const log = logger('core:notifications:push');
@@ -27,6 +28,11 @@ const describeSubscription = (subscription) => {
27
28
  return `web sub=${subscription.id} endpoint=${host}`;
28
29
  }
29
30
  case 'webhook':
31
+ // Intentionally prints the full URL: the webhook endpoint is the
32
+ // subscriber's own configured destination (their choice to expose), and
33
+ // shortening it would make delivery-failure logs impossible to
34
+ // correlate. The apn/fcm tokens below stay shortened because they are
35
+ // device credentials, not user-configured endpoints.
30
36
  return `webhook sub=${subscription.id} url=${subscription.url}`;
31
37
  case 'apn':
32
38
  return `apn sub=${subscription.id} token=${shorten(subscription.apnToken)}`;
@@ -118,7 +124,7 @@ const sendAppFCMPushNotifications = async (subscriptions, payload, notification,
118
124
  return;
119
125
  const serializedPayload = JSON.stringify(payload);
120
126
  const tokens = subscriptions.map((sub) => sub.fcmToken);
121
- if (firebase.apps.length === 0) {
127
+ if (getApps().length === 0) {
122
128
  for (const subscription of subscriptions) {
123
129
  await logFailure(jobLog, log, `FCM not initialized; skipping push to ${describeFcmTarget(account, subscription)}`);
124
130
  }
@@ -129,7 +135,7 @@ const sendAppFCMPushNotifications = async (subscriptions, payload, notification,
129
135
  }
130
136
  let result;
131
137
  try {
132
- result = await firebase.messaging().sendEachForMulticast({
138
+ result = await getMessaging().sendEachForMulticast({
133
139
  tokens,
134
140
  data: { payload: serializedPayload },
135
141
  apns: {
@@ -151,6 +157,11 @@ const sendAppFCMPushNotifications = async (subscriptions, payload, notification,
151
157
  }
152
158
  return;
153
159
  }
160
+ // v14 surfaces per-token failures as `response.error` objects (firebase#3140).
161
+ // No extra v14-specific error mapping is intentionally added here:
162
+ // `formatErrorDetail` (jobLog) already extracts `code`/`statusCode`/`reason`
163
+ // from whatever error shape arrives, so v14's error codes reach the job log
164
+ // pre-formatted.
154
165
  for (let i = 0; i < result.responses.length; i++) {
155
166
  const response = result.responses[i];
156
167
  const subscription = subscriptions[i];
@@ -145,6 +145,7 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
145
145
  speakers?: string[] | undefined;
146
146
  presenters?: string[] | undefined;
147
147
  audience?: string[] | undefined;
148
+ banned?: string[] | undefined;
148
149
  maxSpeakers?: number | undefined;
149
150
  maxPresenters?: number | undefined;
150
151
  maxAudience?: number | undefined;
@@ -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 },
@@ -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.13.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.14.0",
42
41
  "@openpeepshq/fetch-client": "^0.2.1",
43
- "@openpeepshq/i18n": "^0.14.0"
42
+ "@openpeepshq/i18n": "^0.15.0",
43
+ "@openpeepshq/geocoder": "^0.1.2"
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",