@openpeepshq/common 0.1.43
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/LICENSE.md +21 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/lib/adminSections.d.ts +53 -0
- package/dist/lib/adminSections.js +62 -0
- package/dist/lib/attachmentHelpers.d.ts +1 -0
- package/dist/lib/attachmentHelpers.js +13 -0
- package/dist/lib/capabilitiesHelpers.d.ts +118 -0
- package/dist/lib/capabilitiesHelpers.js +238 -0
- package/dist/lib/colors.d.ts +5 -0
- package/dist/lib/colors.js +17 -0
- package/dist/lib/csvHelpers.d.ts +6 -0
- package/dist/lib/csvHelpers.js +17 -0
- package/dist/lib/eventIcs.d.ts +4 -0
- package/dist/lib/eventIcs.js +83 -0
- package/dist/lib/groupHelpers.d.ts +134 -0
- package/dist/lib/groupHelpers.js +216 -0
- package/dist/lib/index.d.ts +17 -0
- package/dist/lib/index.js +17 -0
- package/dist/lib/jamHelpers.d.ts +5 -0
- package/dist/lib/jamHelpers.js +37 -0
- package/dist/lib/markdownHelpers.d.ts +1 -0
- package/dist/lib/markdownHelpers.js +24 -0
- package/dist/lib/mediaDimensions.d.ts +19 -0
- package/dist/lib/mediaDimensions.js +19 -0
- package/dist/lib/postHelpers.d.ts +146 -0
- package/dist/lib/postHelpers.js +144 -0
- package/dist/lib/profileHelpers.d.ts +30 -0
- package/dist/lib/profileHelpers.js +75 -0
- package/dist/lib/pushHelpers.d.ts +4 -0
- package/dist/lib/pushHelpers.js +6 -0
- package/dist/lib/scopeHelpers.d.ts +25 -0
- package/dist/lib/scopeHelpers.js +85 -0
- package/dist/lib/text.d.ts +3 -0
- package/dist/lib/text.js +18 -0
- package/dist/lib/tokenHelpers.d.ts +21 -0
- package/dist/lib/tokenHelpers.js +81 -0
- package/dist/lib/utils.d.ts +43 -0
- package/dist/lib/utils.js +200 -0
- package/dist/types/admin-db.d.ts +62 -0
- package/dist/types/admin-db.js +41 -0
- package/dist/types/admin-email.d.ts +39 -0
- package/dist/types/admin-email.js +41 -0
- package/dist/types/admin-jobs.d.ts +15 -0
- package/dist/types/admin-jobs.js +14 -0
- package/dist/types/admin-performance.d.ts +23 -0
- package/dist/types/admin-performance.js +14 -0
- package/dist/types/analytics.d.ts +583 -0
- package/dist/types/analytics.js +213 -0
- package/dist/types/api.d.ts +20076 -0
- package/dist/types/api.js +492 -0
- package/dist/types/apple-app-site-association.d.ts +50 -0
- package/dist/types/apple-app-site-association.js +38 -0
- package/dist/types/auth.d.ts +367 -0
- package/dist/types/auth.js +17 -0
- package/dist/types/capabilities.d.ts +24 -0
- package/dist/types/capabilities.js +144 -0
- package/dist/types/config.d.ts +858 -0
- package/dist/types/config.js +352 -0
- package/dist/types/db.d.ts +8780 -0
- package/dist/types/db.js +65 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +18 -0
- package/dist/types/internal.d.ts +44337 -0
- package/dist/types/internal.js +154 -0
- package/dist/types/models.d.ts +2619 -0
- package/dist/types/models.js +599 -0
- package/dist/types/notifications.d.ts +148 -0
- package/dist/types/notifications.js +40 -0
- package/dist/types/plugins.d.ts +66 -0
- package/dist/types/plugins.js +29 -0
- package/dist/types/stats.d.ts +10216 -0
- package/dist/types/stats.js +109 -0
- package/dist/types/stripe.d.ts +42 -0
- package/dist/types/stripe.js +35 -0
- package/dist/types/utils.d.ts +84 -0
- package/dist/types/utils.js +39 -0
- package/package.json +54 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import ical, { ICalCalendarMethod } from 'ical-generator';
|
|
2
|
+
import { getJamUrl } from './jamHelpers.js';
|
|
3
|
+
const utcDateFromYmd = (yyyyMmDd) => {
|
|
4
|
+
const [y, m, d] = yyyyMmDd.split('-').map(Number);
|
|
5
|
+
return new Date(Date.UTC(y, m - 1, d));
|
|
6
|
+
};
|
|
7
|
+
const exclusiveEndAfterInclusiveDay = (yyyyMmDd) => {
|
|
8
|
+
const dt = utcDateFromYmd(yyyyMmDd);
|
|
9
|
+
dt.setUTCDate(dt.getUTCDate() + 1);
|
|
10
|
+
return dt;
|
|
11
|
+
};
|
|
12
|
+
const originFromUrl = (url) => {
|
|
13
|
+
if (!url) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
return new URL(url).origin;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/** Prefer a joinable place: physical address, jam URL, then external event URL. */
|
|
24
|
+
const eventLocation = (post, event, postUrl) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const physical = (_b = (_a = event.physicalLocation) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim();
|
|
27
|
+
if (physical) {
|
|
28
|
+
return physical;
|
|
29
|
+
}
|
|
30
|
+
if (event.jam) {
|
|
31
|
+
const jamUrl = getJamUrl(post.id, originFromUrl(postUrl));
|
|
32
|
+
if (jamUrl.startsWith('http')) {
|
|
33
|
+
return jamUrl;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return ((_c = event.url) === null || _c === void 0 ? void 0 : _c.trim()) || undefined;
|
|
37
|
+
};
|
|
38
|
+
export const buildEventIcs = (post, options) => {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
if (post.type !== 'event' || ((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event') {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const event = post.data;
|
|
44
|
+
const calendar = ical({
|
|
45
|
+
prodId: '//OpenPeeps//Event//EN',
|
|
46
|
+
method: ICalCalendarMethod.PUBLISH,
|
|
47
|
+
scale: 'GREGORIAN',
|
|
48
|
+
});
|
|
49
|
+
const link = (_b = event.url) !== null && _b !== void 0 ? _b : options === null || options === void 0 ? void 0 : options.postUrl;
|
|
50
|
+
const summary = ((_c = event.name) === null || _c === void 0 ? void 0 : _c.trim()) || 'Event';
|
|
51
|
+
const description = (_d = event.content) === null || _d === void 0 ? void 0 : _d.trim();
|
|
52
|
+
const location = eventLocation(post, event, options === null || options === void 0 ? void 0 : options.postUrl);
|
|
53
|
+
if (event.wholeDay) {
|
|
54
|
+
const startYmd = event.start.slice(0, 10);
|
|
55
|
+
const lastInclusiveYmd = (_f = (_e = event.end) === null || _e === void 0 ? void 0 : _e.slice(0, 10)) !== null && _f !== void 0 ? _f : startYmd;
|
|
56
|
+
calendar.createEvent({
|
|
57
|
+
id: `openpeeps-event-${post.id}@openpeepshq`,
|
|
58
|
+
allDay: true,
|
|
59
|
+
start: utcDateFromYmd(startYmd),
|
|
60
|
+
end: exclusiveEndAfterInclusiveDay(lastInclusiveYmd),
|
|
61
|
+
summary,
|
|
62
|
+
...(description ? { description } : {}),
|
|
63
|
+
...(location ? { location } : {}),
|
|
64
|
+
...(link ? { url: link } : {}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const start = new Date(event.start);
|
|
69
|
+
const end = event.end
|
|
70
|
+
? new Date(event.end)
|
|
71
|
+
: new Date(start.getTime() + 60 * 60 * 1000);
|
|
72
|
+
calendar.createEvent({
|
|
73
|
+
id: `openpeeps-event-${post.id}@openpeepshq`,
|
|
74
|
+
start,
|
|
75
|
+
end,
|
|
76
|
+
summary,
|
|
77
|
+
...(description ? { description } : {}),
|
|
78
|
+
...(location ? { location } : {}),
|
|
79
|
+
...(link ? { url: link } : {}),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return calendar.toString() + '\r\n';
|
|
83
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { GroupData, GroupMember, GroupWithMeta, ProfileWithMeta } from '../types';
|
|
2
|
+
export declare const groupName: (group?: GroupData) => string;
|
|
3
|
+
export declare const matchesGroupQuery: (group: GroupData, query: string, queryOptions?: {
|
|
4
|
+
handle: boolean;
|
|
5
|
+
displayName: boolean;
|
|
6
|
+
description: boolean;
|
|
7
|
+
}) => boolean | "" | undefined;
|
|
8
|
+
export declare const sortGroupMembers: (members: GroupMember[]) => GroupMember[];
|
|
9
|
+
export declare const canChangeMemberRole: (profile: ProfileWithMeta, group: GroupWithMeta) => boolean;
|
|
10
|
+
export declare const canAddMember: (profile: ProfileWithMeta, group: GroupWithMeta) => boolean;
|
|
11
|
+
export declare const canRemoveMember: (profile: ProfileWithMeta, group: GroupWithMeta) => boolean;
|
|
12
|
+
export declare const isGroupDiscoverable: (group: GroupWithMeta) => boolean;
|
|
13
|
+
/** Posts are only readable by explicit group members (not public/local). */
|
|
14
|
+
export declare const hasMemberOnlyPostsVisibility: (capabilities: GroupData["capabilities"] | undefined) => boolean;
|
|
15
|
+
export declare const groupCapabilityTemplates: {
|
|
16
|
+
defaultGroup: {
|
|
17
|
+
name: string;
|
|
18
|
+
capabilities: {
|
|
19
|
+
none: {
|
|
20
|
+
add: string[];
|
|
21
|
+
};
|
|
22
|
+
local: {
|
|
23
|
+
add: string[];
|
|
24
|
+
};
|
|
25
|
+
member: {
|
|
26
|
+
add: string[];
|
|
27
|
+
remove: string[];
|
|
28
|
+
};
|
|
29
|
+
moderator: {
|
|
30
|
+
add: string[];
|
|
31
|
+
};
|
|
32
|
+
admin: {
|
|
33
|
+
add: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
defaultGroupClosedCommunity: {
|
|
38
|
+
name: string;
|
|
39
|
+
capabilities: {
|
|
40
|
+
local: {
|
|
41
|
+
add: string[];
|
|
42
|
+
};
|
|
43
|
+
member: {
|
|
44
|
+
add: string[];
|
|
45
|
+
remove: string[];
|
|
46
|
+
};
|
|
47
|
+
moderator: {
|
|
48
|
+
add: string[];
|
|
49
|
+
};
|
|
50
|
+
admin: {
|
|
51
|
+
add: string[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
publicGroup: {
|
|
56
|
+
name: string;
|
|
57
|
+
capabilities: {
|
|
58
|
+
none: {
|
|
59
|
+
add: string[];
|
|
60
|
+
};
|
|
61
|
+
member: {
|
|
62
|
+
add: string[];
|
|
63
|
+
};
|
|
64
|
+
moderator: {
|
|
65
|
+
add: string[];
|
|
66
|
+
};
|
|
67
|
+
admin: {
|
|
68
|
+
add: string[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
localGroup: {
|
|
73
|
+
name: string;
|
|
74
|
+
capabilities: {
|
|
75
|
+
local: {
|
|
76
|
+
add: string[];
|
|
77
|
+
};
|
|
78
|
+
member: {
|
|
79
|
+
add: string[];
|
|
80
|
+
};
|
|
81
|
+
moderator: {
|
|
82
|
+
add: string[];
|
|
83
|
+
};
|
|
84
|
+
admin: {
|
|
85
|
+
add: string[];
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
privateGroup: {
|
|
90
|
+
name: string;
|
|
91
|
+
capabilities: {
|
|
92
|
+
member: {
|
|
93
|
+
add: string[];
|
|
94
|
+
};
|
|
95
|
+
moderator: {
|
|
96
|
+
add: string[];
|
|
97
|
+
};
|
|
98
|
+
admin: {
|
|
99
|
+
add: string[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
limitedPostingGroup: {
|
|
104
|
+
name: string;
|
|
105
|
+
capabilities: {
|
|
106
|
+
member: {
|
|
107
|
+
add: string[];
|
|
108
|
+
};
|
|
109
|
+
moderator: {
|
|
110
|
+
add: string[];
|
|
111
|
+
};
|
|
112
|
+
admin: {
|
|
113
|
+
add: string[];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
lockedGroup: {
|
|
118
|
+
name: string;
|
|
119
|
+
capabilities: {
|
|
120
|
+
none: {
|
|
121
|
+
add: string[];
|
|
122
|
+
};
|
|
123
|
+
member: {
|
|
124
|
+
add: string[];
|
|
125
|
+
};
|
|
126
|
+
moderator: {
|
|
127
|
+
add: string[];
|
|
128
|
+
};
|
|
129
|
+
admin: {
|
|
130
|
+
add: string[];
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { checkCapabilities, getGroupCapabilitiesByRoles, } from './capabilitiesHelpers.js';
|
|
2
|
+
import { profileName } from './profileHelpers.js';
|
|
3
|
+
const containsIgnoreCase = (candidate, query) => candidate.toLowerCase().indexOf(query.toLowerCase()) > -1;
|
|
4
|
+
export const groupName = (group) => (group === null || group === void 0 ? void 0 : group.displayName) || (group === null || group === void 0 ? void 0 : group.handle) || '';
|
|
5
|
+
export const matchesGroupQuery = (group, query, queryOptions = { handle: true, displayName: true, description: false }) => (queryOptions.handle && containsIgnoreCase(group.handle, query)) ||
|
|
6
|
+
(queryOptions.displayName &&
|
|
7
|
+
group.displayName &&
|
|
8
|
+
containsIgnoreCase(group.displayName, query)) ||
|
|
9
|
+
(queryOptions.description &&
|
|
10
|
+
group.description &&
|
|
11
|
+
containsIgnoreCase(group.description, query));
|
|
12
|
+
export const sortGroupMembers = (members) => {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = members === null || members === void 0 ? void 0 : members.sort((a, b) => profileName(a.profile).localeCompare(profileName(b.profile)))) !== null && _a !== void 0 ? _a : [];
|
|
15
|
+
};
|
|
16
|
+
export const canChangeMemberRole = (profile, group) => {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
return checkCapabilities(['core-groups-changeMemberRole'], getGroupCapabilitiesByRoles((_c = (_b = (_a = profile.memberships) === null || _a === void 0 ? void 0 : _a.find((m) => m.group.id === group.id)) === null || _b === void 0 ? void 0 : _b.roles) !== null && _c !== void 0 ? _c : [], group)).success;
|
|
19
|
+
};
|
|
20
|
+
export const canAddMember = (profile, group) => {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
return checkCapabilities(['core-groups-addMember'], getGroupCapabilitiesByRoles((_c = (_b = (_a = profile.memberships) === null || _a === void 0 ? void 0 : _a.find((m) => m.group.id === group.id)) === null || _b === void 0 ? void 0 : _b.roles) !== null && _c !== void 0 ? _c : [], group)).success;
|
|
23
|
+
};
|
|
24
|
+
export const canRemoveMember = (profile, group) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
return checkCapabilities(['core-groups-removeMember'], getGroupCapabilitiesByRoles((_c = (_b = (_a = profile.memberships) === null || _a === void 0 ? void 0 : _a.find((m) => m.group.id === group.id)) === null || _b === void 0 ? void 0 : _b.roles) !== null && _c !== void 0 ? _c : [], group)).success;
|
|
27
|
+
};
|
|
28
|
+
export const isGroupDiscoverable = (group) => checkCapabilities(['core-groups-read'], getGroupCapabilitiesByRoles(['none'], group)).success;
|
|
29
|
+
/** Posts are only readable by explicit group members (not public/local). */
|
|
30
|
+
export const hasMemberOnlyPostsVisibility = (capabilities) => {
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
return !((_b = (_a = capabilities === null || capabilities === void 0 ? void 0 : capabilities.none) === null || _a === void 0 ? void 0 : _a.add) === null || _b === void 0 ? void 0 : _b.includes('core-posts-read')) &&
|
|
33
|
+
!((_d = (_c = capabilities === null || capabilities === void 0 ? void 0 : capabilities.local) === null || _c === void 0 ? void 0 : _c.add) === null || _d === void 0 ? void 0 : _d.includes('core-posts-read'));
|
|
34
|
+
};
|
|
35
|
+
export const groupCapabilityTemplates = {
|
|
36
|
+
defaultGroup: {
|
|
37
|
+
name: 'defaultGroup',
|
|
38
|
+
capabilities: {
|
|
39
|
+
none: {
|
|
40
|
+
add: [
|
|
41
|
+
'core-groups-read',
|
|
42
|
+
'core-posts-read',
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
local: {
|
|
46
|
+
add: [
|
|
47
|
+
'core-groups-join',
|
|
48
|
+
'core-posts-react',
|
|
49
|
+
'core-posts-reply',
|
|
50
|
+
'core-posts-rsvp',
|
|
51
|
+
'core-posts-vote',
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
member: {
|
|
55
|
+
add: [
|
|
56
|
+
'core-posts-create-*',
|
|
57
|
+
'core-posts-reply',
|
|
58
|
+
'core-posts-rsvp',
|
|
59
|
+
'core-posts-vote',
|
|
60
|
+
],
|
|
61
|
+
remove: ['core-posts-create-event'],
|
|
62
|
+
},
|
|
63
|
+
moderator: {
|
|
64
|
+
add: ['core-posts-*'],
|
|
65
|
+
},
|
|
66
|
+
admin: {
|
|
67
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
defaultGroupClosedCommunity: {
|
|
72
|
+
name: 'defaultGroupClosedCommunity',
|
|
73
|
+
capabilities: {
|
|
74
|
+
local: {
|
|
75
|
+
add: [
|
|
76
|
+
'core-groups-read',
|
|
77
|
+
'core-posts-read',
|
|
78
|
+
'core-groups-join',
|
|
79
|
+
'core-posts-react',
|
|
80
|
+
'core-posts-reply',
|
|
81
|
+
'core-posts-rsvp',
|
|
82
|
+
'core-posts-vote',
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
member: {
|
|
86
|
+
add: [
|
|
87
|
+
'core-posts-create-*',
|
|
88
|
+
'core-posts-reply',
|
|
89
|
+
'core-posts-rsvp',
|
|
90
|
+
'core-posts-vote',
|
|
91
|
+
],
|
|
92
|
+
remove: ['core-posts-create-event'],
|
|
93
|
+
},
|
|
94
|
+
moderator: {
|
|
95
|
+
add: ['core-posts-*'],
|
|
96
|
+
},
|
|
97
|
+
admin: {
|
|
98
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
publicGroup: {
|
|
103
|
+
name: 'publicGroup',
|
|
104
|
+
capabilities: {
|
|
105
|
+
none: {
|
|
106
|
+
add: [
|
|
107
|
+
'core-groups-read',
|
|
108
|
+
'core-groups-join',
|
|
109
|
+
'core-posts-read',
|
|
110
|
+
'core-posts-react',
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
member: {
|
|
114
|
+
add: [
|
|
115
|
+
'core-posts-create-*',
|
|
116
|
+
'core-posts-reply',
|
|
117
|
+
'core-posts-rsvp',
|
|
118
|
+
'core-posts-vote',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
moderator: {
|
|
122
|
+
add: ['core-posts-*'],
|
|
123
|
+
},
|
|
124
|
+
admin: {
|
|
125
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
localGroup: {
|
|
130
|
+
name: 'localGroup',
|
|
131
|
+
capabilities: {
|
|
132
|
+
local: {
|
|
133
|
+
add: [
|
|
134
|
+
'core-groups-read',
|
|
135
|
+
'core-groups-join',
|
|
136
|
+
'core-posts-read',
|
|
137
|
+
'core-posts-react',
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
member: {
|
|
141
|
+
add: [
|
|
142
|
+
'core-posts-create-*',
|
|
143
|
+
'core-posts-reply',
|
|
144
|
+
'core-posts-rsvp',
|
|
145
|
+
'core-posts-vote',
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
moderator: {
|
|
149
|
+
add: ['core-posts-*'],
|
|
150
|
+
},
|
|
151
|
+
admin: {
|
|
152
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
privateGroup: {
|
|
157
|
+
name: 'privateGroup',
|
|
158
|
+
capabilities: {
|
|
159
|
+
member: {
|
|
160
|
+
add: [
|
|
161
|
+
'core-groups-read',
|
|
162
|
+
'core-posts-read',
|
|
163
|
+
'core-posts-create-*',
|
|
164
|
+
'core-posts-react',
|
|
165
|
+
'core-posts-reply',
|
|
166
|
+
'core-posts-rsvp',
|
|
167
|
+
'core-posts-vote',
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
moderator: {
|
|
171
|
+
add: ['core-posts-*'],
|
|
172
|
+
},
|
|
173
|
+
admin: {
|
|
174
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
limitedPostingGroup: {
|
|
179
|
+
name: 'limitedPostingGroup',
|
|
180
|
+
capabilities: {
|
|
181
|
+
member: {
|
|
182
|
+
add: [
|
|
183
|
+
'core-groups-read',
|
|
184
|
+
'core-posts-read',
|
|
185
|
+
'core-posts-react',
|
|
186
|
+
'core-posts-reply',
|
|
187
|
+
'core-posts-rsvp',
|
|
188
|
+
'core-posts-vote',
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
moderator: {
|
|
192
|
+
add: ['core-posts-*'],
|
|
193
|
+
},
|
|
194
|
+
admin: {
|
|
195
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
lockedGroup: {
|
|
200
|
+
name: 'lockedGroup',
|
|
201
|
+
capabilities: {
|
|
202
|
+
none: {
|
|
203
|
+
add: ['core-groups-read', 'core-posts-read', 'core-posts-react'],
|
|
204
|
+
},
|
|
205
|
+
member: {
|
|
206
|
+
add: ['core-posts-reply', 'core-posts-rsvp', 'core-posts-vote'],
|
|
207
|
+
},
|
|
208
|
+
moderator: {
|
|
209
|
+
add: ['core-posts-*'],
|
|
210
|
+
},
|
|
211
|
+
admin: {
|
|
212
|
+
add: ['core-posts-*', 'core-groups-*'],
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './utils';
|
|
2
|
+
export * from './profileHelpers';
|
|
3
|
+
export * from './text';
|
|
4
|
+
export * from './postHelpers';
|
|
5
|
+
export * from './capabilitiesHelpers';
|
|
6
|
+
export * from './adminSections';
|
|
7
|
+
export * from './groupHelpers';
|
|
8
|
+
export * from './colors';
|
|
9
|
+
export * from './markdownHelpers';
|
|
10
|
+
export * from './attachmentHelpers';
|
|
11
|
+
export * from './eventIcs';
|
|
12
|
+
export * from './tokenHelpers';
|
|
13
|
+
export * from './jamHelpers';
|
|
14
|
+
export * from './scopeHelpers';
|
|
15
|
+
export * from './pushHelpers';
|
|
16
|
+
export * from './mediaDimensions';
|
|
17
|
+
export * from './csvHelpers';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './utils.js';
|
|
2
|
+
export * from './profileHelpers.js';
|
|
3
|
+
export * from './text.js';
|
|
4
|
+
export * from './postHelpers.js';
|
|
5
|
+
export * from './capabilitiesHelpers.js';
|
|
6
|
+
export * from './adminSections.js';
|
|
7
|
+
export * from './groupHelpers.js';
|
|
8
|
+
export * from './colors.js';
|
|
9
|
+
export * from './markdownHelpers.js';
|
|
10
|
+
export * from './attachmentHelpers.js';
|
|
11
|
+
export * from './eventIcs.js';
|
|
12
|
+
export * from './tokenHelpers.js';
|
|
13
|
+
export * from './jamHelpers.js';
|
|
14
|
+
export * from './scopeHelpers.js';
|
|
15
|
+
export * from './pushHelpers.js';
|
|
16
|
+
export * from './mediaDimensions.js';
|
|
17
|
+
export * from './csvHelpers.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Jam, PublicPost, PublicProfile } from "../types";
|
|
2
|
+
export declare const getJamUrl: (id: string, origin: string | undefined) => string;
|
|
3
|
+
export declare const jamFromEvent: (event: PublicPost) => Jam | undefined;
|
|
4
|
+
export declare const canModerateJam: (profile: Pick<PublicProfile, "id"> | undefined, post: PublicPost) => boolean;
|
|
5
|
+
export declare const canAccessJamRecordings: (profile: PublicProfile | undefined, post: PublicPost) => boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const getJamUrl = (id, origin) => {
|
|
2
|
+
if (!id) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
if (!origin)
|
|
6
|
+
return `/events/${id}/jam`;
|
|
7
|
+
return `${origin}/events/${id}/jam`;
|
|
8
|
+
};
|
|
9
|
+
export const jamFromEvent = (event) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'event' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.jam)) {
|
|
12
|
+
return event.data.jam;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
export const canModerateJam = (profile, post) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return !!(profile &&
|
|
19
|
+
((_b = (_a = jamFromEvent(post)) === null || _a === void 0 ? void 0 : _a.moderators) === null || _b === void 0 ? void 0 : _b.includes(profile.id)));
|
|
20
|
+
};
|
|
21
|
+
export const canAccessJamRecordings = (profile, post) => {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
if (!profile) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (post.profile.id === profile.id) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (((_a = post.data) === null || _a === void 0 ? void 0 : _a.type) !== 'event') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const event = post.data;
|
|
33
|
+
if ((_b = event.moderators) === null || _b === void 0 ? void 0 : _b.includes(profile.id)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return !!((_d = (_c = event.jam) === null || _c === void 0 ? void 0 : _c.moderators) === null || _d === void 0 ? void 0 : _d.includes(profile.id));
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const firstNWords: (markdown: string | undefined, n: number) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const firstNWords = (markdown, n) => {
|
|
2
|
+
if (!markdown)
|
|
3
|
+
return '';
|
|
4
|
+
// Regular expression to match words and markdown links.
|
|
5
|
+
const regex = /\[.*?\]\(.*?\)|(\w+)/g;
|
|
6
|
+
let wordCount = 0;
|
|
7
|
+
const firstTwelveWords = [];
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = regex.exec(markdown)) !== null) {
|
|
10
|
+
// Check if the match is a link or a regular word.
|
|
11
|
+
if (match[1]) { // It's a regular word
|
|
12
|
+
firstTwelveWords.push(match[1]);
|
|
13
|
+
wordCount++;
|
|
14
|
+
}
|
|
15
|
+
else { // It's a markdown link - treat it as one word
|
|
16
|
+
firstTwelveWords.push(match[0]); // Add the entire link string
|
|
17
|
+
wordCount++;
|
|
18
|
+
}
|
|
19
|
+
if (wordCount >= n) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return firstTwelveWords.join(" ");
|
|
24
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum width (px) we store header/banner images at.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally larger than the web center column (~669px) to leave headroom
|
|
5
|
+
* for other clients and future layout changes. Header uploads are cropped to
|
|
6
|
+
* their aspect ratio and then scaled down to this width if necessary (never
|
|
7
|
+
* upscaled), which keeps banners sharp without bloating storage.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HEADER_IMAGE_MAX_WIDTH = 800;
|
|
10
|
+
/** Aspect ratio used for event/article header banners. */
|
|
11
|
+
export declare const EVENT_HEADER_ASPECT_RATIO = "16:9";
|
|
12
|
+
/**
|
|
13
|
+
* Aspect ratio for profile/group cover banners. Uploads are cropped to this
|
|
14
|
+
* ratio; display containers use the same ratio. Banners that arrive with a
|
|
15
|
+
* different ratio (federation or older uploads) are shown with `object-cover`
|
|
16
|
+
* so they fill the 3:1 banner (center-cropped) rather than being letterboxed
|
|
17
|
+
* with grey gaps.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PROFILE_GROUP_HEADER_ASPECT_RATIO = "3:1";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum width (px) we store header/banner images at.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally larger than the web center column (~669px) to leave headroom
|
|
5
|
+
* for other clients and future layout changes. Header uploads are cropped to
|
|
6
|
+
* their aspect ratio and then scaled down to this width if necessary (never
|
|
7
|
+
* upscaled), which keeps banners sharp without bloating storage.
|
|
8
|
+
*/
|
|
9
|
+
export const HEADER_IMAGE_MAX_WIDTH = 800;
|
|
10
|
+
/** Aspect ratio used for event/article header banners. */
|
|
11
|
+
export const EVENT_HEADER_ASPECT_RATIO = '16:9';
|
|
12
|
+
/**
|
|
13
|
+
* Aspect ratio for profile/group cover banners. Uploads are cropped to this
|
|
14
|
+
* ratio; display containers use the same ratio. Banners that arrive with a
|
|
15
|
+
* different ratio (federation or older uploads) are shown with `object-cover`
|
|
16
|
+
* so they fill the 3:1 banner (center-cropped) rather than being letterboxed
|
|
17
|
+
* with grey gaps.
|
|
18
|
+
*/
|
|
19
|
+
export const PROFILE_GROUP_HEADER_ASPECT_RATIO = '3:1';
|