@openpeepshq/core 0.11.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/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/stats/mapping.d.ts +1 -0
- package/package.json +4 -4
|
@@ -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;
|
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,6 +1,6 @@
|
|
|
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": {
|
|
@@ -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.
|
|
41
|
-
"@openpeepshq/
|
|
40
|
+
"@openpeepshq/common": "0.13.0",
|
|
41
|
+
"@openpeepshq/geocoder": "^0.1.2",
|
|
42
42
|
"@openpeepshq/fetch-client": "^0.2.1",
|
|
43
|
-
"@openpeepshq/
|
|
43
|
+
"@openpeepshq/i18n": "^0.14.0"
|
|
44
44
|
},
|
|
45
45
|
"main": "dist/index.js",
|
|
46
46
|
"types": "dist/index.d.ts",
|