@openpeepshq/core 0.10.0 → 0.12.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.
- package/dist/db/pg/filters/profiles.d.ts +1 -0
- package/dist/db/pg/filters/profiles.js +7 -1
- package/dist/notifications/defaultNotifications/jamStarted/index.js +5 -40
- package/dist/notifications/defaultNotifications/jamStarted/recipients.d.ts +16 -0
- package/dist/notifications/defaultNotifications/jamStarted/recipients.js +119 -0
- package/dist/notifications/helpers.js +6 -0
- package/dist/posts/finders.d.ts +1 -0
- package/dist/posts/helpers/index.d.ts +4 -0
- package/dist/posts/mapping.d.ts +14 -0
- package/dist/posts/mutations.d.ts +9 -3
- package/dist/posts/mutations.js +17 -3
- package/dist/profiles/finders.d.ts +3 -1
- package/dist/profiles/finders.js +11 -2
- package/dist/sentry/index.d.ts +39 -0
- package/dist/sentry/index.js +38 -0
- package/dist/seo/index.d.ts +4 -3
- package/dist/seo/index.js +7 -4
- package/dist/stats/mapping.d.ts +1 -0
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { eq, gt, ne, notInArray } from 'drizzle-orm';
|
|
1
|
+
import { eq, gt, isNull, ne, notInArray, or, sql } from 'drizzle-orm';
|
|
2
2
|
import { profiles } from '../schema/documents.js';
|
|
3
3
|
import { profileActivityScoreExpr } from '../queries/activity.js';
|
|
4
4
|
import { pgSql } from './types.js';
|
|
@@ -7,4 +7,10 @@ export const profileFilters = {
|
|
|
7
7
|
type: (type) => pgSql(eq(profiles.type, type)),
|
|
8
8
|
notIdIn: (ids) => ids.length ? pgSql(notInArray(profiles.id, ids)) : undefined,
|
|
9
9
|
activityScorePositive: (start, end) => pgSql(gt(profileActivityScoreExpr(profiles, { start, end }), 0)),
|
|
10
|
+
// Writer contract: only body->>'discoverable' = 'false' hides a profile;
|
|
11
|
+
// an absent flag stays listed. That is the single canonical encoding — the
|
|
12
|
+
// profile screens persist it via PATCH /profiles/current, and
|
|
13
|
+
// loadLocalActor (federation/actors.ts) projects the same boolean onto the
|
|
14
|
+
// ActivityPub actor.
|
|
15
|
+
discoverable: () => pgSql(or(isNull(sql `${profiles.body}->>'discoverable'`), sql `${profiles.body}->>'discoverable' <> 'false'`)),
|
|
10
16
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { listProfiles, listGroupMembers, findProfile, } from '@openpeepshq/core/profiles';
|
|
2
1
|
import { maybeCreateNotification } from '@openpeepshq/core/notifications';
|
|
3
2
|
import { getJamUrl, occurrenceForJamStart, profileName, } from '@openpeepshq/common/lib';
|
|
4
3
|
import { listJamStarts } from '../../../jams/finders.js';
|
|
5
4
|
import { PUSH_INVALIDATE } from '../../pushInvalidation.js';
|
|
5
|
+
import { jamStartAudience } from './recipients.js';
|
|
6
6
|
// The start row is written in the same request, then the notification is
|
|
7
7
|
// queued. They are not linked by id, so match on time.
|
|
8
8
|
const START_MATCH_WINDOW_MS = 15 * 60 * 1000;
|
|
@@ -34,51 +34,16 @@ const eventHandler = async (...args) => {
|
|
|
34
34
|
if (!jam) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const notify = (recipientProfile) => maybeCreateNotification(recipientProfile, {
|
|
37
|
+
const notify = (recipientProfile, groupId) => maybeCreateNotification(recipientProfile, {
|
|
38
38
|
type: 'jamStarted',
|
|
39
39
|
fromProfileId: profile.id,
|
|
40
40
|
postId: post.id,
|
|
41
|
+
...(groupId ? { groupId } : {}),
|
|
41
42
|
...(recurrenceId ? { data: { recurrenceId } } : {}),
|
|
42
43
|
});
|
|
43
|
-
|
|
44
|
-
for (const recipientProfile of await listProfiles()) {
|
|
45
|
-
if (profile.id !== recipientProfile?.id) {
|
|
46
|
-
await notify(recipientProfile);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const recipients = new Set();
|
|
52
|
-
const skipRecipient = (recipient) => !profile ||
|
|
53
|
-
!recipient ||
|
|
54
|
-
profile.id === recipient?.id ||
|
|
55
|
-
recipients.has(recipient);
|
|
56
|
-
if (jam.moderators) {
|
|
57
|
-
for (const id of [...jam.moderators, ...(jam.speakers || [])]) {
|
|
58
|
-
const moderatorProfile = await findProfile(id);
|
|
59
|
-
if (skipRecipient(moderatorProfile))
|
|
60
|
-
continue;
|
|
61
|
-
recipients.add(moderatorProfile);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (post.audience) {
|
|
65
|
-
for (const audience of post.audience) {
|
|
66
|
-
const audienceProfile = await findProfile(audience?.id);
|
|
67
|
-
if (skipRecipient(audienceProfile))
|
|
68
|
-
continue;
|
|
69
|
-
recipients.add(audienceProfile);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (post.visibility === 'group' && post.group) {
|
|
73
|
-
for (const { profile: recipient } of await listGroupMembers(post.group)) {
|
|
74
|
-
const recipientProfile = await findProfile(recipient?.id);
|
|
75
|
-
if (skipRecipient(recipientProfile))
|
|
76
|
-
continue;
|
|
77
|
-
recipients.add(recipientProfile);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
44
|
+
const { profiles: recipients, groupId } = await jamStartAudience(profile, post, recurrenceId);
|
|
80
45
|
for (const recipientProfile of recipients) {
|
|
81
|
-
await notify(recipientProfile);
|
|
46
|
+
await notify(recipientProfile, groupId);
|
|
82
47
|
}
|
|
83
48
|
};
|
|
84
49
|
const expander = async (notification) => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PostWithMeta, ProfileWithMeta } from '@openpeepshq/common/types';
|
|
2
|
+
export interface JamStartAudience {
|
|
3
|
+
profiles: ProfileWithMeta[];
|
|
4
|
+
groupId?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Recipients for a "started a jam" alert. Community-wide jams (public/local)
|
|
8
|
+
* only broadcast when the creator opted in; group and direct jams notify
|
|
9
|
+
* their own audience and the designated moderators/speakers by default. The
|
|
10
|
+
* group notification level then applies: `off` silences the group's jams
|
|
11
|
+
* (including for designated moderators/speakers, which the delivery pipeline
|
|
12
|
+
* drops), `mostRelevant` keeps members with an RSVP (yes/maybe) to this event
|
|
13
|
+
* plus designated moderators/speakers, which the delivery pipeline defers to
|
|
14
|
+
* this handler for.
|
|
15
|
+
*/
|
|
16
|
+
export declare const jamStartAudience: (creator: ProfileWithMeta, post: PostWithMeta, recurrenceId: string | undefined) => Promise<JamStartAudience>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { calculateEffectiveRsvps, occurrenceForJamStart, } from '@openpeepshq/common/lib';
|
|
2
|
+
import { findProfile, listProfiles, listGroupMembers, } from '@openpeepshq/core/profiles';
|
|
3
|
+
import { findProfileSettings } from '../../../profileSettings/index.js';
|
|
4
|
+
import { groupNotificationLevelFor } from '../../helpers.js';
|
|
5
|
+
const yesOrMaybe = (response) => response === 'yes' || response === 'tentative';
|
|
6
|
+
/** Effective (yes/maybe) RSVP profile ids for the jam occurrence being opened. */
|
|
7
|
+
const rsvpedProfileIds = (post, recurrenceId) => {
|
|
8
|
+
// `post.data` is narrowed to the event discriminant by the caller.
|
|
9
|
+
const occurrence = occurrenceForJamStart(post.data, {
|
|
10
|
+
recurrenceId,
|
|
11
|
+
});
|
|
12
|
+
return new Set(calculateEffectiveRsvps(post, occurrence?.recurrenceId)
|
|
13
|
+
.filter((rsvp) => yesOrMaybe(rsvp.response))
|
|
14
|
+
.map((rsvp) => rsvp.profile.id));
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Profiles the creator explicitly designated for the jam (moderators and
|
|
18
|
+
* speakers). They are offered to the audience builder unconditionally — the
|
|
19
|
+
* per-group level gate is applied later in the delivery pipeline
|
|
20
|
+
* (`maybeCreateNotification`), so a designated recipient whose group is `off`
|
|
21
|
+
* is still dropped there; at `mostRelevant` the pipeline defers to this
|
|
22
|
+
* handler for `jamStarted`, so a designated recipient passes. `known` is the
|
|
23
|
+
* set of audience profiles already loaded for this post, so a designated
|
|
24
|
+
* recipient who is also in the audience is not re-fetched; dedup against the
|
|
25
|
+
* accumulating audience happens in `jamStartAudience`'s `add`, which drops
|
|
26
|
+
* any profile already present.
|
|
27
|
+
*/
|
|
28
|
+
const designatedJamRecipients = async (jam, known) => {
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
const recipients = [];
|
|
31
|
+
for (const id of [...(jam.moderators ?? []), ...(jam.speakers ?? [])]) {
|
|
32
|
+
if (!id || seen.has(id))
|
|
33
|
+
continue;
|
|
34
|
+
seen.add(id);
|
|
35
|
+
const cached = known.get(id);
|
|
36
|
+
if (cached) {
|
|
37
|
+
recipients.push(cached);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const profile = await findProfile(id);
|
|
41
|
+
if (profile)
|
|
42
|
+
recipients.push(profile);
|
|
43
|
+
}
|
|
44
|
+
return recipients;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Recipients for a "started a jam" alert. Community-wide jams (public/local)
|
|
48
|
+
* only broadcast when the creator opted in; group and direct jams notify
|
|
49
|
+
* their own audience and the designated moderators/speakers by default. The
|
|
50
|
+
* group notification level then applies: `off` silences the group's jams
|
|
51
|
+
* (including for designated moderators/speakers, which the delivery pipeline
|
|
52
|
+
* drops), `mostRelevant` keeps members with an RSVP (yes/maybe) to this event
|
|
53
|
+
* plus designated moderators/speakers, which the delivery pipeline defers to
|
|
54
|
+
* this handler for.
|
|
55
|
+
*/
|
|
56
|
+
export const jamStartAudience = async (creator, post, recurrenceId) => {
|
|
57
|
+
if (!post.data || post.data.type !== 'event')
|
|
58
|
+
return { profiles: [] };
|
|
59
|
+
const event = post.data;
|
|
60
|
+
const jam = event.jam;
|
|
61
|
+
if (!jam)
|
|
62
|
+
return { profiles: [] };
|
|
63
|
+
const groupId = post.group?.id;
|
|
64
|
+
if (['local', 'public'].includes(post.visibility)) {
|
|
65
|
+
if (!jam.notifyEveryone)
|
|
66
|
+
return { profiles: [] };
|
|
67
|
+
return {
|
|
68
|
+
profiles: (await listProfiles()).filter((candidate) => candidate && candidate.id !== creator.id),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
let audience = [];
|
|
72
|
+
if (post.visibility === 'group') {
|
|
73
|
+
if (!post.group)
|
|
74
|
+
return { profiles: [] };
|
|
75
|
+
for (const member of await listGroupMembers(post.group)) {
|
|
76
|
+
if (member.profile?.id)
|
|
77
|
+
audience.push(member.profile);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
for (const audienceEntry of post.audience ?? []) {
|
|
82
|
+
if (audienceEntry?.id)
|
|
83
|
+
audience.push(audienceEntry);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const profiles = [];
|
|
87
|
+
const add = (profile) => {
|
|
88
|
+
if (!profile || profile.id === creator.id)
|
|
89
|
+
return;
|
|
90
|
+
if (profiles.some((existing) => existing.id === profile.id))
|
|
91
|
+
return;
|
|
92
|
+
profiles.push(profile);
|
|
93
|
+
};
|
|
94
|
+
// Lazy: only members at `mostRelevant` consult the RSVP set. On the direct
|
|
95
|
+
// path the level is always `all` (no group), so it stays uncaptured — that
|
|
96
|
+
// holds because a post carrying `post.group` takes the group branch, so on
|
|
97
|
+
// the direct path `groupId` is undefined and `groupNotificationLevelFor`
|
|
98
|
+
// short-circuits to `all` before any level is looked up.
|
|
99
|
+
let rsvpedIds;
|
|
100
|
+
const hasRsvp = (profileId) => {
|
|
101
|
+
rsvpedIds ??= rsvpedProfileIds(post, recurrenceId);
|
|
102
|
+
return rsvpedIds.has(profileId);
|
|
103
|
+
};
|
|
104
|
+
for (const profile of audience) {
|
|
105
|
+
if (!profile || profile.id === creator.id)
|
|
106
|
+
continue;
|
|
107
|
+
const settings = await findProfileSettings(profile.id);
|
|
108
|
+
const level = groupNotificationLevelFor(settings, groupId);
|
|
109
|
+
if (level === 'off')
|
|
110
|
+
continue;
|
|
111
|
+
if (level === 'mostRelevant' && !hasRsvp(profile.id))
|
|
112
|
+
continue;
|
|
113
|
+
add(profile);
|
|
114
|
+
}
|
|
115
|
+
const loaded = new Map(audience.filter(Boolean).map((profile) => [profile.id, profile]));
|
|
116
|
+
for (const profile of await designatedJamRecipients(jam, loaded))
|
|
117
|
+
add(profile);
|
|
118
|
+
return { profiles, ...(groupId ? { groupId } : {}) };
|
|
119
|
+
};
|
|
@@ -16,6 +16,7 @@ const groupScopedNotificationTypes = [
|
|
|
16
16
|
'newGroupPost',
|
|
17
17
|
'groupMemberJoined',
|
|
18
18
|
'groupMemberLeft',
|
|
19
|
+
'jamStarted',
|
|
19
20
|
];
|
|
20
21
|
export const groupNotificationLevelFor = (profileSettings, groupId) => {
|
|
21
22
|
if (!groupId)
|
|
@@ -33,6 +34,11 @@ export const allowsGroupNotification = ({ level, type, followsAuthor, }) => {
|
|
|
33
34
|
if (level === 'off')
|
|
34
35
|
return false;
|
|
35
36
|
if (level === 'mostRelevant') {
|
|
37
|
+
// Jam-start alerts are RSVP-aware: the jamStarted handler only offers
|
|
38
|
+
// profiles with an effective RSVP, so anything reaching the gate counts
|
|
39
|
+
// as relevant.
|
|
40
|
+
if (type === 'jamStarted')
|
|
41
|
+
return true;
|
|
36
42
|
return type === 'newGroupPost' && followsAuthor;
|
|
37
43
|
}
|
|
38
44
|
return true;
|
package/dist/posts/finders.d.ts
CHANGED
|
@@ -149,6 +149,7 @@ export declare const baseEventsFeed: (profile?: ProfileWithMeta) => Mapping<{
|
|
|
149
149
|
maxPresenters?: number | undefined;
|
|
150
150
|
maxAudience?: number | undefined;
|
|
151
151
|
waitingRoom?: boolean | undefined;
|
|
152
|
+
notifyEveryone?: boolean | undefined;
|
|
152
153
|
} | undefined;
|
|
153
154
|
physicalLocation?: {
|
|
154
155
|
text: string;
|
|
@@ -140,6 +140,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
140
140
|
maxPresenters?: number | undefined;
|
|
141
141
|
maxAudience?: number | undefined;
|
|
142
142
|
waitingRoom?: boolean | undefined;
|
|
143
|
+
notifyEveryone?: boolean | undefined;
|
|
143
144
|
} | undefined;
|
|
144
145
|
physicalLocation?: {
|
|
145
146
|
text: string;
|
|
@@ -374,6 +375,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
374
375
|
maxPresenters?: number | undefined;
|
|
375
376
|
maxAudience?: number | undefined;
|
|
376
377
|
waitingRoom?: boolean | undefined;
|
|
378
|
+
notifyEveryone?: boolean | undefined;
|
|
377
379
|
} | undefined;
|
|
378
380
|
physicalLocation?: {
|
|
379
381
|
text: string;
|
|
@@ -638,6 +640,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
638
640
|
maxPresenters?: number | undefined;
|
|
639
641
|
maxAudience?: number | undefined;
|
|
640
642
|
waitingRoom?: boolean | undefined;
|
|
643
|
+
notifyEveryone?: boolean | undefined;
|
|
641
644
|
} | undefined;
|
|
642
645
|
physicalLocation?: {
|
|
643
646
|
text: string;
|
|
@@ -872,6 +875,7 @@ export declare const entryConnector: (db: import("../../db").PgDb, from: Profile
|
|
|
872
875
|
maxPresenters?: number | undefined;
|
|
873
876
|
maxAudience?: number | undefined;
|
|
874
877
|
waitingRoom?: boolean | undefined;
|
|
878
|
+
notifyEveryone?: boolean | undefined;
|
|
875
879
|
} | undefined;
|
|
876
880
|
physicalLocation?: {
|
|
877
881
|
text: string;
|
package/dist/posts/mapping.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ export declare const threadPreviewMappingForProfile: (profile?: {
|
|
|
140
140
|
maxPresenters?: number | undefined;
|
|
141
141
|
maxAudience?: number | undefined;
|
|
142
142
|
waitingRoom?: boolean | undefined;
|
|
143
|
+
notifyEveryone?: boolean | undefined;
|
|
143
144
|
} | undefined;
|
|
144
145
|
physicalLocation?: {
|
|
145
146
|
text: string;
|
|
@@ -386,6 +387,7 @@ export declare const postsWithReplyCountMapping: Mapping<{
|
|
|
386
387
|
maxPresenters?: number | undefined;
|
|
387
388
|
maxAudience?: number | undefined;
|
|
388
389
|
waitingRoom?: boolean | undefined;
|
|
390
|
+
notifyEveryone?: boolean | undefined;
|
|
389
391
|
} | undefined;
|
|
390
392
|
physicalLocation?: {
|
|
391
393
|
text: string;
|
|
@@ -627,6 +629,7 @@ export declare const postsWithReplyCountMapping: Mapping<{
|
|
|
627
629
|
maxPresenters?: number | undefined;
|
|
628
630
|
maxAudience?: number | undefined;
|
|
629
631
|
waitingRoom?: boolean | undefined;
|
|
632
|
+
notifyEveryone?: boolean | undefined;
|
|
630
633
|
} | undefined;
|
|
631
634
|
physicalLocation?: {
|
|
632
635
|
text: string;
|
|
@@ -872,6 +875,7 @@ export declare const postsWithReplyCountMapping: Mapping<{
|
|
|
872
875
|
maxPresenters?: number | undefined;
|
|
873
876
|
maxAudience?: number | undefined;
|
|
874
877
|
waitingRoom?: boolean | undefined;
|
|
878
|
+
notifyEveryone?: boolean | undefined;
|
|
875
879
|
} | undefined;
|
|
876
880
|
physicalLocation?: {
|
|
877
881
|
text: string;
|
|
@@ -1114,6 +1118,7 @@ export declare const postsWithReplyToCountMapping: Mapping<{
|
|
|
1114
1118
|
maxPresenters?: number | undefined;
|
|
1115
1119
|
maxAudience?: number | undefined;
|
|
1116
1120
|
waitingRoom?: boolean | undefined;
|
|
1121
|
+
notifyEveryone?: boolean | undefined;
|
|
1117
1122
|
} | undefined;
|
|
1118
1123
|
physicalLocation?: {
|
|
1119
1124
|
text: string;
|
|
@@ -1355,6 +1360,7 @@ export declare const postsWithReplyToCountMapping: Mapping<{
|
|
|
1355
1360
|
maxPresenters?: number | undefined;
|
|
1356
1361
|
maxAudience?: number | undefined;
|
|
1357
1362
|
waitingRoom?: boolean | undefined;
|
|
1363
|
+
notifyEveryone?: boolean | undefined;
|
|
1358
1364
|
} | undefined;
|
|
1359
1365
|
physicalLocation?: {
|
|
1360
1366
|
text: string;
|
|
@@ -1600,6 +1606,7 @@ export declare const postsWithReplyToCountMapping: Mapping<{
|
|
|
1600
1606
|
maxPresenters?: number | undefined;
|
|
1601
1607
|
maxAudience?: number | undefined;
|
|
1602
1608
|
waitingRoom?: boolean | undefined;
|
|
1609
|
+
notifyEveryone?: boolean | undefined;
|
|
1603
1610
|
} | undefined;
|
|
1604
1611
|
physicalLocation?: {
|
|
1605
1612
|
text: string;
|
|
@@ -1842,6 +1849,7 @@ export declare const postsMapping: Mapping<{
|
|
|
1842
1849
|
maxPresenters?: number | undefined;
|
|
1843
1850
|
maxAudience?: number | undefined;
|
|
1844
1851
|
waitingRoom?: boolean | undefined;
|
|
1852
|
+
notifyEveryone?: boolean | undefined;
|
|
1845
1853
|
} | undefined;
|
|
1846
1854
|
physicalLocation?: {
|
|
1847
1855
|
text: string;
|
|
@@ -2081,6 +2089,7 @@ export declare const postsAuthMapping: Mapping<{
|
|
|
2081
2089
|
maxPresenters?: number | undefined;
|
|
2082
2090
|
maxAudience?: number | undefined;
|
|
2083
2091
|
waitingRoom?: boolean | undefined;
|
|
2092
|
+
notifyEveryone?: boolean | undefined;
|
|
2084
2093
|
} | undefined;
|
|
2085
2094
|
physicalLocation?: {
|
|
2086
2095
|
text: string;
|
|
@@ -2321,6 +2330,7 @@ export declare const postsMappingForProfile: (profile?: {
|
|
|
2321
2330
|
maxPresenters?: number | undefined;
|
|
2322
2331
|
maxAudience?: number | undefined;
|
|
2323
2332
|
waitingRoom?: boolean | undefined;
|
|
2333
|
+
notifyEveryone?: boolean | undefined;
|
|
2324
2334
|
} | undefined;
|
|
2325
2335
|
physicalLocation?: {
|
|
2326
2336
|
text: string;
|
|
@@ -2561,6 +2571,7 @@ export declare const postContextMappingForProfile: (profile?: {
|
|
|
2561
2571
|
maxPresenters?: number | undefined;
|
|
2562
2572
|
maxAudience?: number | undefined;
|
|
2563
2573
|
waitingRoom?: boolean | undefined;
|
|
2574
|
+
notifyEveryone?: boolean | undefined;
|
|
2564
2575
|
} | undefined;
|
|
2565
2576
|
physicalLocation?: {
|
|
2566
2577
|
text: string;
|
|
@@ -2800,6 +2811,7 @@ export declare const conversationLeavesMapping: Mapping<{
|
|
|
2800
2811
|
maxPresenters?: number | undefined;
|
|
2801
2812
|
maxAudience?: number | undefined;
|
|
2802
2813
|
waitingRoom?: boolean | undefined;
|
|
2814
|
+
notifyEveryone?: boolean | undefined;
|
|
2803
2815
|
} | undefined;
|
|
2804
2816
|
physicalLocation?: {
|
|
2805
2817
|
text: string;
|
|
@@ -3040,6 +3052,7 @@ export declare const conversationLeavesMappingForProfile: (profile?: {
|
|
|
3040
3052
|
maxPresenters?: number | undefined;
|
|
3041
3053
|
maxAudience?: number | undefined;
|
|
3042
3054
|
waitingRoom?: boolean | undefined;
|
|
3055
|
+
notifyEveryone?: boolean | undefined;
|
|
3043
3056
|
} | undefined;
|
|
3044
3057
|
physicalLocation?: {
|
|
3045
3058
|
text: string;
|
|
@@ -3278,6 +3291,7 @@ export declare const postIdsMapping: Mapping<{
|
|
|
3278
3291
|
maxPresenters?: number | undefined;
|
|
3279
3292
|
maxAudience?: number | undefined;
|
|
3280
3293
|
waitingRoom?: boolean | undefined;
|
|
3294
|
+
notifyEveryone?: boolean | undefined;
|
|
3281
3295
|
} | undefined;
|
|
3282
3296
|
physicalLocation?: {
|
|
3283
3297
|
text: string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { AuthorizationData, Answer, PostWithMeta, PostData, Profile, ProfileWithMeta, ReactionData, RsvpRequest, RsvpResponse } from '@openpeepshq/common/types';
|
|
1
|
+
import { AuthorizationData, Answer, PostWithMeta, PostData, Profile, ProfileWithMeta, ReactionData, Role, RsvpRequest, RsvpResponse } from '@openpeepshq/common/types';
|
|
2
2
|
import { PostDataUnion } from '@openpeepshq/common/types';
|
|
3
|
-
export declare const createPost: (data: PostDataUnion, profile: Profile
|
|
3
|
+
export declare const createPost: (data: PostDataUnion, profile: Profile & {
|
|
4
|
+
roles?: Role[];
|
|
5
|
+
}, postData: PostData, relations?: {
|
|
4
6
|
inReplyToId?: string | null;
|
|
5
7
|
repostId?: string;
|
|
6
8
|
audience?: Profile[] | null;
|
|
7
9
|
groupId?: string | null;
|
|
8
10
|
}) => Promise<PostWithMeta>;
|
|
9
|
-
export declare const updatePost: (post: PostWithMeta, profile: Profile
|
|
11
|
+
export declare const updatePost: (post: PostWithMeta, profile: Profile & {
|
|
12
|
+
roles?: Role[];
|
|
13
|
+
}, data: PostDataUnion) => Promise<PostWithMeta>;
|
|
10
14
|
export declare const reactToPost: (post: PostWithMeta, profile: Profile, data: ReactionData) => Promise<void>;
|
|
11
15
|
export declare const retractReaction: (post: PostWithMeta, profile: Profile, data: ReactionData) => Promise<import("../db/pg/map").WithId<({
|
|
12
16
|
type: "create";
|
|
@@ -137,6 +141,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile, dat
|
|
|
137
141
|
maxPresenters?: number | undefined;
|
|
138
142
|
maxAudience?: number | undefined;
|
|
139
143
|
waitingRoom?: boolean | undefined;
|
|
144
|
+
notifyEveryone?: boolean | undefined;
|
|
140
145
|
} | undefined;
|
|
141
146
|
physicalLocation?: {
|
|
142
147
|
text: string;
|
|
@@ -371,6 +376,7 @@ export declare const retractReaction: (post: PostWithMeta, profile: Profile, dat
|
|
|
371
376
|
maxPresenters?: number | undefined;
|
|
372
377
|
maxAudience?: number | undefined;
|
|
373
378
|
waitingRoom?: boolean | undefined;
|
|
379
|
+
notifyEveryone?: boolean | undefined;
|
|
374
380
|
} | undefined;
|
|
375
381
|
physicalLocation?: {
|
|
376
382
|
text: string;
|
package/dist/posts/mutations.js
CHANGED
|
@@ -13,7 +13,7 @@ import { profilesCache } from '../profiles/cache.js';
|
|
|
13
13
|
import { findOrCreateHashtag } from '../hashtags/index.js';
|
|
14
14
|
import { hub } from '../events/index.js';
|
|
15
15
|
import { listUnseenGroupPostIds } from './unseenCounts.js';
|
|
16
|
-
import { canManageEventRsvps, capacityRsvpDecision, eventDataForDbUpdate, getEffectiveRsvp, instanceRsvpIdsForProfile, isOneToOneDm, normalizeEventDataForSave, overlaySeriesRsvpEntries, participantIds, passThroughUndefined, rsvpCancelNotice, rsvpTargetsPastEvent, sameRecurrenceId, } from '@openpeepshq/common/lib';
|
|
16
|
+
import { canManageEventRsvps, capacityRsvpDecision, eventDataForDbUpdate, getEffectiveRsvp, instanceRsvpIdsForProfile, isOneToOneDm, normalizeEventDataForSave, overlaySeriesRsvpEntries, participantIds, passThroughUndefined, rsvpCancelNotice, rsvpTargetsPastEvent, sameRecurrenceId, withoutCommunityJamNotifyEveryone, } from '@openpeepshq/common/lib';
|
|
17
17
|
import { forbidden, notFound, unprocessableRequest } from '../errors/index.js';
|
|
18
18
|
import { areBlocked, hasBlockAmong } from '../profiles/blocks.js';
|
|
19
19
|
import { rebuildEventOccurrences, clearEventOccurrences, } from './eventOccurrences.js';
|
|
@@ -22,7 +22,11 @@ import { publishWaitlistPlans } from './waitlistOfferJobs.js';
|
|
|
22
22
|
import { capacitySyncTargets, syncCapacityOccurrences, withRsvpCapacityLock, } from './waitlist.js';
|
|
23
23
|
import { config } from '../config/index.js';
|
|
24
24
|
import { localObjectScalars } from '../federation/identity.js';
|
|
25
|
-
export const createPost = async (data,
|
|
25
|
+
export const createPost = async (data,
|
|
26
|
+
// Roles are present on server callers (`ensureLocalProfile`) and drive the
|
|
27
|
+
// broadcast-flag capability check; internal callers pass a plain Profile,
|
|
28
|
+
// for which the flag is stripped rather than broadcast.
|
|
29
|
+
profile, postData, relations = {}) => {
|
|
26
30
|
if (data.type === 'event') {
|
|
27
31
|
data = normalizeEventDataForSave(data);
|
|
28
32
|
}
|
|
@@ -59,6 +63,14 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
59
63
|
if (group) {
|
|
60
64
|
postData = { ...postData, visibility: 'group' };
|
|
61
65
|
}
|
|
66
|
+
// The broadcast flag survives only on community-wide posts created by a
|
|
67
|
+
// profile that can announce (same rule as the announce endpoint). Key off
|
|
68
|
+
// the post's own final visibility — the same field the notification handler
|
|
69
|
+
// reads — so a payload carrying `visibility: 'public'` plus a group can
|
|
70
|
+
// never keep a flag the jam-start path would treat as instance-wide.
|
|
71
|
+
if (data.type === 'event') {
|
|
72
|
+
data = withoutCommunityJamNotifyEveryone(data, postData.visibility, profile.roles);
|
|
73
|
+
}
|
|
62
74
|
const hashtags = extractHashtags(data);
|
|
63
75
|
const id = uuidv7();
|
|
64
76
|
const domain = (await config()).activityPub.defaultDomain;
|
|
@@ -122,7 +134,9 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
122
134
|
};
|
|
123
135
|
export const updatePost = async (post, profile, data) => {
|
|
124
136
|
const previousEvent = post.data?.type === 'event' ? post.data : undefined;
|
|
125
|
-
const normalized = data.type === 'event'
|
|
137
|
+
const normalized = data.type === 'event'
|
|
138
|
+
? withoutCommunityJamNotifyEveryone(normalizeEventDataForSave(data), post.visibility, profile.roles)
|
|
139
|
+
: data;
|
|
126
140
|
const dataForDb = normalized.type === 'event'
|
|
127
141
|
? eventDataForDbUpdate(previousEvent, normalized)
|
|
128
142
|
: normalized;
|
|
@@ -3,7 +3,9 @@ export declare const findProfile: (profileId: string) => Promise<ProfileWithMeta
|
|
|
3
3
|
export declare const findProfileByHandle: (handle: string) => Promise<ProfileWithMeta | undefined>;
|
|
4
4
|
export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles';
|
|
5
5
|
export declare const existsProfileByHandle: (handle: string) => Promise<boolean>;
|
|
6
|
-
export declare const listProfiles: (viewer?: ProfileWithMeta
|
|
6
|
+
export declare const listProfiles: (viewer?: ProfileWithMeta, options?: {
|
|
7
|
+
directoryView?: boolean;
|
|
8
|
+
}) => Promise<ProfileWithMeta[]>;
|
|
7
9
|
export declare const listProfilesByRole: (role: Role) => Promise<ProfileWithMeta[]>;
|
|
8
10
|
export declare const listProfilesByAccount: (account: Account) => Promise<ProfileWithMeta[]>;
|
|
9
11
|
export declare const listProfilesWithCapabilities: (capabilities: string[]) => Promise<ProfileWithMeta[]>;
|
package/dist/profiles/finders.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { accountProfileRelation, baseProfilesMapping, membersRelation, profileRoleRelation, } from './mapping.js';
|
|
2
2
|
import { allpeepDb } from '../db/index.js';
|
|
3
3
|
import { profileFilters } from '../db/pg/filters/index.js';
|
|
4
|
-
import { blockedPairIds, getUniqueBy } from '@openpeepshq/common/lib';
|
|
4
|
+
import { blockedPairIds, checkRoleCapabilities, getUniqueBy, } from '@openpeepshq/common/lib';
|
|
5
5
|
import { rolesMapping } from '../roles/mapping.js';
|
|
6
6
|
import { findRolesByCapabilities } from '../roles/finders.js';
|
|
7
7
|
import { expandProfiles, followFinder } from './helpers.js';
|
|
@@ -13,10 +13,19 @@ export const findProfile = (profileId) => getProfile(profileId);
|
|
|
13
13
|
export const findProfileByHandle = (handle) => getProfileByHandle(handle);
|
|
14
14
|
export { findProfileByHandleAndDomain, findProfileByUri, } from '../federation/profiles.js';
|
|
15
15
|
export const existsProfileByHandle = (handle) => getProfileByHandle(handle, true).then(Boolean);
|
|
16
|
-
|
|
16
|
+
// Mirrors canSeeGroupFilter: member-directory viewers without
|
|
17
|
+
// core-profiles-read — including anonymous public-community visitors — only
|
|
18
|
+
// see profiles that have not opted out of the directory. It ands the same
|
|
19
|
+
// `profileFilters.discoverable()` SQL predicate defined in
|
|
20
|
+
// db/pg/filters/profiles.ts, so readers can jump straight to the predicate.
|
|
21
|
+
const directoryFilter = (viewer) => checkRoleCapabilities(viewer?.roles ?? [], ['core-profiles-read']).success
|
|
22
|
+
? undefined
|
|
23
|
+
: profileFilters.discoverable();
|
|
24
|
+
export const listProfiles = (viewer, options = {}) => allpeepDb()
|
|
17
25
|
.then(({ db }) => baseProfilesMapping
|
|
18
26
|
.filter(profileFilters.notGuest())
|
|
19
27
|
.filter(profileFilters.notIdIn(blockedPairIds(viewer)))
|
|
28
|
+
.filter(options.directoryView ? directoryFilter(viewer) : undefined)
|
|
20
29
|
.all(db))
|
|
21
30
|
.then(expandProfiles);
|
|
22
31
|
export const listProfilesByRole = (role) => allpeepDb()
|
package/dist/sentry/index.d.ts
CHANGED
|
@@ -24,6 +24,45 @@ export declare const getSentryService: () => SentryService | undefined;
|
|
|
24
24
|
* — never fall back to `NODE_ENV` (Docker images always set that to production).
|
|
25
25
|
*/
|
|
26
26
|
export declare const resolveSentryEnvironment: (explicit?: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Integration names of `@sentry/node@10.x`'s vendored DB instrumentations
|
|
29
|
+
* (the SDK vendors its own copies; 9.x's standalone
|
|
30
|
+
* `@opentelemetry/instrumentation-*` packages left the tree). They emit the
|
|
31
|
+
* `db.user` span attribute unconditionally — GHSA-qqmp-wf37-98f9's behavior,
|
|
32
|
+
* invisible to `pnpm audit` because the copies live inside the audited-clean
|
|
33
|
+
* package. The only one that can ever match a module in this repo is
|
|
34
|
+
* Postgres (drizzle/pg); the rest are inert here, but they are dropped
|
|
35
|
+
* together so this list stays the complete set of vendored `db.user`
|
|
36
|
+
* emitters.
|
|
37
|
+
*
|
|
38
|
+
* Trade-off (documented decision): the filter matches on the integration
|
|
39
|
+
* `name`, and the SDK's `filterDuplicates` resolves duplicate integrations by
|
|
40
|
+
* name too. A future *user-supplied* integration that happens to be named
|
|
41
|
+
* exactly `Postgres`/`Mysql`/`Mysql2`/`Tedious`/`Knex` would therefore also
|
|
42
|
+
* be dropped from the final set. That is accepted: the five names are the
|
|
43
|
+
* SDK's own vendored names, so a user integration carrying one would collide
|
|
44
|
+
* with the vendored copy anyway, and dropping both is the safe outcome.
|
|
45
|
+
*
|
|
46
|
+
* Layout provenance: this list is pinned by the canary in
|
|
47
|
+
* `sentry.test.ts`, which resolves the vendored-instrumentation path from the
|
|
48
|
+
* installed `@sentry/node` package — that resolved path, not any directory
|
|
49
|
+
* names quoted in comments, is the source of truth for the layout.
|
|
50
|
+
*/
|
|
51
|
+
export declare const VENDORED_DB_INTEGRATION_NAMES: readonly ["Postgres", "Mysql", "Mysql2", "Tedious", "Knex"];
|
|
52
|
+
/**
|
|
53
|
+
* The callable shape `initSentry` passes to `Sentry.init`'s `integrations`
|
|
54
|
+
* option: a function that maps the SDK's own auto-detected default list to a
|
|
55
|
+
* filtered subset. The function form is load-bearing — a callable *replaces*
|
|
56
|
+
* the default set entirely, whereas the array form *keeps* the defaults and
|
|
57
|
+
* overlays by name (which would re-admit the five DB integrations).
|
|
58
|
+
*/
|
|
59
|
+
export type SentryDefaultIntegrations = (integrations: ReturnType<typeof Sentry.getAutoPerformanceIntegrations>) => ReturnType<typeof Sentry.getAutoPerformanceIntegrations>;
|
|
60
|
+
/**
|
|
61
|
+
* Removes the vendored DB integrations (see
|
|
62
|
+
* `VENDORED_DB_INTEGRATION_NAMES`) from the SDK default set so no `db.user`
|
|
63
|
+
* attribute is emitted. Wired into `Sentry.init` below as the callable form.
|
|
64
|
+
*/
|
|
65
|
+
export declare const withoutVendoredDbIntegrations: SentryDefaultIntegrations;
|
|
27
66
|
/** Re-apply community tags on the current isolation scope (per-request). */
|
|
28
67
|
export declare const applyCommunitySentryTags: () => void;
|
|
29
68
|
/**
|
package/dist/sentry/index.js
CHANGED
|
@@ -40,6 +40,43 @@ export const resolveSentryEnvironment = (explicit) => {
|
|
|
40
40
|
return fromEnvironment;
|
|
41
41
|
return 'local';
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Integration names of `@sentry/node@10.x`'s vendored DB instrumentations
|
|
45
|
+
* (the SDK vendors its own copies; 9.x's standalone
|
|
46
|
+
* `@opentelemetry/instrumentation-*` packages left the tree). They emit the
|
|
47
|
+
* `db.user` span attribute unconditionally — GHSA-qqmp-wf37-98f9's behavior,
|
|
48
|
+
* invisible to `pnpm audit` because the copies live inside the audited-clean
|
|
49
|
+
* package. The only one that can ever match a module in this repo is
|
|
50
|
+
* Postgres (drizzle/pg); the rest are inert here, but they are dropped
|
|
51
|
+
* together so this list stays the complete set of vendored `db.user`
|
|
52
|
+
* emitters.
|
|
53
|
+
*
|
|
54
|
+
* Trade-off (documented decision): the filter matches on the integration
|
|
55
|
+
* `name`, and the SDK's `filterDuplicates` resolves duplicate integrations by
|
|
56
|
+
* name too. A future *user-supplied* integration that happens to be named
|
|
57
|
+
* exactly `Postgres`/`Mysql`/`Mysql2`/`Tedious`/`Knex` would therefore also
|
|
58
|
+
* be dropped from the final set. That is accepted: the five names are the
|
|
59
|
+
* SDK's own vendored names, so a user integration carrying one would collide
|
|
60
|
+
* with the vendored copy anyway, and dropping both is the safe outcome.
|
|
61
|
+
*
|
|
62
|
+
* Layout provenance: this list is pinned by the canary in
|
|
63
|
+
* `sentry.test.ts`, which resolves the vendored-instrumentation path from the
|
|
64
|
+
* installed `@sentry/node` package — that resolved path, not any directory
|
|
65
|
+
* names quoted in comments, is the source of truth for the layout.
|
|
66
|
+
*/
|
|
67
|
+
export const VENDORED_DB_INTEGRATION_NAMES = [
|
|
68
|
+
'Postgres',
|
|
69
|
+
'Mysql',
|
|
70
|
+
'Mysql2',
|
|
71
|
+
'Tedious',
|
|
72
|
+
'Knex',
|
|
73
|
+
];
|
|
74
|
+
/**
|
|
75
|
+
* Removes the vendored DB integrations (see
|
|
76
|
+
* `VENDORED_DB_INTEGRATION_NAMES`) from the SDK default set so no `db.user`
|
|
77
|
+
* attribute is emitted. Wired into `Sentry.init` below as the callable form.
|
|
78
|
+
*/
|
|
79
|
+
export const withoutVendoredDbIntegrations = (integrations) => integrations.filter((i) => !VENDORED_DB_INTEGRATION_NAMES.some((n) => i.name === n));
|
|
43
80
|
/** Re-apply community tags on the current isolation scope (per-request). */
|
|
44
81
|
export const applyCommunitySentryTags = () => {
|
|
45
82
|
if (communityHostname) {
|
|
@@ -92,6 +129,7 @@ export const initSentry = (options = {}) => {
|
|
|
92
129
|
tracesSampleRate: Number.isFinite(tracesSampleRate)
|
|
93
130
|
? tracesSampleRate
|
|
94
131
|
: 0.1,
|
|
132
|
+
integrations: withoutVendoredDbIntegrations,
|
|
95
133
|
});
|
|
96
134
|
if (communityHostname) {
|
|
97
135
|
Sentry.setTag(COMMUNITY_HOSTNAME_TAG, communityHostname);
|
package/dist/seo/index.d.ts
CHANGED
|
@@ -28,9 +28,10 @@ export { seoRoute, type SeoRoute, type SeoRouteKind } from './route';
|
|
|
28
28
|
* their own, so they are covered by the post paths.
|
|
29
29
|
*
|
|
30
30
|
* Profiles are opt-in: a crawled profile page is cached by search engines long
|
|
31
|
-
* after the member leaves.
|
|
32
|
-
*
|
|
33
|
-
* anonymous visitor can already browse
|
|
31
|
+
* after the member leaves. The sitemap uses the same directory view
|
|
32
|
+
* (`directoryView`) as the anonymous `/members` list, so enabling this exposes
|
|
33
|
+
* exactly the profiles an anonymous visitor can already browse — never ones
|
|
34
|
+
* that opted out of the directory.
|
|
34
35
|
*/
|
|
35
36
|
export declare const crawlableEntries: ({ indexProfiles, }: {
|
|
36
37
|
indexProfiles: boolean;
|
package/dist/seo/index.js
CHANGED
|
@@ -38,15 +38,18 @@ const excerpt = (value, fallback) => {
|
|
|
38
38
|
* their own, so they are covered by the post paths.
|
|
39
39
|
*
|
|
40
40
|
* Profiles are opt-in: a crawled profile page is cached by search engines long
|
|
41
|
-
* after the member leaves.
|
|
42
|
-
*
|
|
43
|
-
* anonymous visitor can already browse
|
|
41
|
+
* after the member leaves. The sitemap uses the same directory view
|
|
42
|
+
* (`directoryView`) as the anonymous `/members` list, so enabling this exposes
|
|
43
|
+
* exactly the profiles an anonymous visitor can already browse — never ones
|
|
44
|
+
* that opted out of the directory.
|
|
44
45
|
*/
|
|
45
46
|
export const crawlableEntries = async ({ indexProfiles, }) => {
|
|
46
47
|
const [posts, groups, profiles] = await Promise.all([
|
|
47
48
|
listPosts(ANONYMOUS, { limit: PER_KIND_LIMIT }),
|
|
48
49
|
listGroups(ANONYMOUS),
|
|
49
|
-
indexProfiles
|
|
50
|
+
indexProfiles
|
|
51
|
+
? listProfiles(undefined, { directoryView: true })
|
|
52
|
+
: Promise.resolve([]),
|
|
50
53
|
]);
|
|
51
54
|
const entities = [
|
|
52
55
|
...posts.map((post) => ({
|
package/dist/stats/mapping.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ export declare const postsWithActivityScoreMapping: import("../db/pg/map").Mappi
|
|
|
132
132
|
maxPresenters?: number | undefined;
|
|
133
133
|
maxAudience?: number | undefined;
|
|
134
134
|
waitingRoom?: boolean | undefined;
|
|
135
|
+
notifyEveryone?: boolean | undefined;
|
|
135
136
|
} | undefined;
|
|
136
137
|
physicalLocation?: {
|
|
137
138
|
text: string;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@asteasolutions/zod-to-openapi": "^8.5.0",
|
|
8
8
|
"@keyv/redis": "^5.1.4",
|
|
9
|
-
"@sentry/node": "^
|
|
9
|
+
"@sentry/node": "^10.78.0",
|
|
10
10
|
"apns2": "^12.2.0",
|
|
11
11
|
"archiver": "^7.0.1",
|
|
12
12
|
"bcrypt": "^5.1.1",
|
|
@@ -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.
|
|
40
|
+
"@openpeepshq/common": "0.13.0",
|
|
41
41
|
"@openpeepshq/geocoder": "^0.1.2",
|
|
42
42
|
"@openpeepshq/fetch-client": "^0.2.1",
|
|
43
|
-
"@openpeepshq/i18n": "^0.
|
|
43
|
+
"@openpeepshq/i18n": "^0.14.0"
|
|
44
44
|
},
|
|
45
45
|
"main": "dist/index.js",
|
|
46
46
|
"types": "dist/index.d.ts",
|