@openpeepshq/react 0.7.0 → 0.7.1

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.
Files changed (188) hide show
  1. package/dist/components/configuration/ConfigurationCategory.js +3 -2
  2. package/dist/components/configuration/ConfigurationList.js +1 -1
  3. package/dist/components/form/LocationInput.js +1 -1
  4. package/dist/components/jams/JamCapacityGate.js +1 -1
  5. package/dist/components/jams/JamConference.js +2 -0
  6. package/dist/components/jams/JamParticipantConference.js +2 -0
  7. package/dist/components/jams/JamRoom.js +2 -3
  8. package/dist/components/jams/LiveJamsSection.js +8 -2
  9. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  10. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  11. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  12. package/dist/components/jams/dropLateAudio.js +115 -0
  13. package/dist/components/jams/index.d.ts +1 -0
  14. package/dist/components/jams/index.js +1 -0
  15. package/dist/components/notifications/TypedNotification.js +46 -4
  16. package/dist/components/post/Markdown.d.ts +2 -2
  17. package/dist/components/post/Markdown.js +1 -1
  18. package/dist/components/post/attachmentPreview.js +1 -1
  19. package/dist/components/post/pieces/Attachments.js +23 -17
  20. package/dist/components/post/pieces/EventRsvpButton.js +37 -7
  21. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  22. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  23. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  24. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  25. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  26. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  27. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  28. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  29. package/dist/components/post/pieces/PostActions.js +20 -12
  30. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  31. package/dist/components/post/pieces/ShareMenu.js +40 -7
  32. package/dist/components/post/post-form/EventForm.js +10 -2
  33. package/dist/components/post/types/Article.js +1 -1
  34. package/dist/components/post/types/article/FullArticle.js +1 -1
  35. package/dist/components/post/types/event/CardEvent.js +2 -1
  36. package/dist/components/post/types/event/FullEvent.js +22 -13
  37. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  38. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  39. package/dist/components/preview-link/PreviewLink.js +1 -1
  40. package/dist/components/preview-link/helpers.d.ts +5 -0
  41. package/dist/components/preview-link/helpers.js +27 -1
  42. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  43. package/dist/components/preview-link/local/WelcomePreview.js +6 -0
  44. package/dist/components/profile/Avatar.js +2 -2
  45. package/dist/components/profile/ProfileFromId.js +1 -1
  46. package/dist/components/server-data/context.d.ts +1 -0
  47. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  48. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  49. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  50. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  51. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  52. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  53. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  54. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  55. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  56. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  57. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  58. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  59. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  60. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  61. package/dist/hooks/events/useEventForm.d.ts +1 -0
  62. package/dist/hooks/events/useEventRsvp.d.ts +11 -2
  63. package/dist/hooks/events/useEventRsvp.js +46 -5
  64. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  65. package/dist/hooks/groups/useNewGroup.js +22 -2
  66. package/dist/hooks/index.d.ts +5 -1
  67. package/dist/hooks/index.js +4 -1
  68. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  69. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  70. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  71. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  72. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  73. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  74. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  75. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  76. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  77. package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
  78. package/dist/hooks/posts/useResourceComposer.js +4 -2
  79. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  80. package/dist/hooks/posts/useShareMenu.js +7 -0
  81. package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
  82. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  83. package/dist/hooks/useWelcomePreview.d.ts +13 -0
  84. package/dist/hooks/useWelcomePreview.js +39 -0
  85. package/dist/lib/groupFormErrors.d.ts +1 -0
  86. package/dist/lib/groupFormErrors.js +5 -2
  87. package/dist/lib/threadHelpers.js +1 -5
  88. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  89. package/dist/pages/admin/Diagnostics.js +1 -1
  90. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  91. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  92. package/dist/pages/admin/Invites.js +5 -3
  93. package/dist/pages/admin/Media.d.ts +1 -0
  94. package/dist/pages/admin/Media.js +135 -0
  95. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  96. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  97. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  98. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  99. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  100. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  101. package/dist/pages/auth/Register.js +30 -8
  102. package/dist/pages/conversations/Show.js +11 -0
  103. package/dist/pages/index.d.ts +3 -0
  104. package/dist/pages/index.js +3 -0
  105. package/dist/pages/jams/Index.js +2 -4
  106. package/dist/pages/settings/PublicProfile.js +15 -3
  107. package/dist/pwa/sw.d.ts +0 -1
  108. package/dist/react-native.d.ts +1 -0
  109. package/dist/react-native.js +1 -0
  110. package/dist/stores/newPosts.d.ts +4 -2
  111. package/dist/stores/newPosts.js +6 -1
  112. package/package.json +12 -7
  113. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  114. package/src/components/configuration/ConfigurationList.tsx +6 -1
  115. package/src/components/form/LocationInput.tsx +7 -1
  116. package/src/components/jams/JamCapacityGate.tsx +1 -1
  117. package/src/components/jams/JamConference.tsx +2 -0
  118. package/src/components/jams/JamParticipantConference.tsx +2 -0
  119. package/src/components/jams/JamRoom.tsx +2 -6
  120. package/src/components/jams/LiveJamsSection.tsx +16 -2
  121. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  122. package/src/components/jams/dropLateAudio.ts +153 -0
  123. package/src/components/jams/index.ts +1 -0
  124. package/src/components/notifications/TypedNotification.tsx +81 -9
  125. package/src/components/post/Markdown.tsx +8 -2
  126. package/src/components/post/attachmentPreview.ts +1 -3
  127. package/src/components/post/pieces/Attachments.tsx +93 -78
  128. package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
  129. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  130. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  131. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  132. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  133. package/src/components/post/pieces/PostActions.tsx +73 -42
  134. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  135. package/src/components/post/post-form/EventForm.tsx +26 -0
  136. package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
  137. package/src/components/post/types/Article.tsx +1 -1
  138. package/src/components/post/types/article/FullArticle.tsx +2 -2
  139. package/src/components/post/types/event/CardEvent.tsx +26 -14
  140. package/src/components/post/types/event/FullEvent.tsx +48 -35
  141. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  142. package/src/components/post/types/note/FullNote.tsx +1 -4
  143. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  144. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  145. package/src/components/preview-link/PreviewLink.tsx +2 -7
  146. package/src/components/preview-link/helpers.ts +32 -1
  147. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  148. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  149. package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
  150. package/src/components/profile/Avatar.tsx +6 -2
  151. package/src/components/profile/ProfileFromId.tsx +1 -5
  152. package/src/components/resources/ResourceCard.tsx +0 -1
  153. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  154. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  155. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  156. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  157. package/src/css.d.ts +4 -0
  158. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  159. package/src/hooks/events/useEventRsvp.ts +51 -7
  160. package/src/hooks/groups/useNewGroup.ts +28 -3
  161. package/src/hooks/index.ts +8 -1
  162. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  163. package/src/hooks/posts/useResourceComposer.ts +8 -6
  164. package/src/hooks/posts/useShareMenu.ts +9 -0
  165. package/src/hooks/useWelcomePreview.ts +57 -0
  166. package/src/i18n/I18nProvider.tsx +1 -4
  167. package/src/lib/groupFormErrors.ts +9 -2
  168. package/src/lib/threadHelpers.ts +1 -5
  169. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  170. package/src/pages/admin/Diagnostics.tsx +4 -0
  171. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  172. package/src/pages/admin/Invites.tsx +23 -1
  173. package/src/pages/admin/Media.tsx +290 -0
  174. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  175. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  176. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  177. package/src/pages/auth/Register.tsx +33 -4
  178. package/src/pages/conversations/Show.tsx +11 -0
  179. package/src/pages/index.ts +3 -0
  180. package/src/pages/jams/Index.tsx +2 -6
  181. package/src/pages/settings/PublicProfile.tsx +20 -2
  182. package/src/pwa/sw.ts +6 -3
  183. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  184. package/src/react-native.ts +1 -0
  185. package/src/stores/newPosts.ts +6 -1
  186. package/src/streaming.ts +3 -3
  187. package/dist/setupTests.d.ts +0 -1
  188. package/dist/setupTests.js +0 -5
@@ -0,0 +1,223 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { Lock, X } from 'lucide-react';
3
+ import {
4
+ classifyAdditionalForbiddenHandle,
5
+ collectAdditionalForbiddenHandles,
6
+ forbiddenHandles,
7
+ normalizeForbiddenHandle,
8
+ type CommunityConfig,
9
+ } from '@openpeepshq/common/types';
10
+ import { useT, useSetPageHeader, useOpenpeeps } from '../../../index';
11
+ import { Button, Input, Toast } from '@openpeepshq/react-ui';
12
+
13
+ const sameHandles = (left: readonly string[], right: readonly string[]) =>
14
+ left.length === right.length &&
15
+ left.every((handle, i) => handle === right[i]);
16
+
17
+ export function AdminConfigurationCommunityForbiddenUsernames() {
18
+ const t = useT();
19
+ const { openpeepsApi } = useOpenpeeps();
20
+ const configQuery = openpeepsApi.admin.useConfigRead(
21
+ 'openpeeps',
22
+ 'community',
23
+ );
24
+ const updateConfig = openpeepsApi.admin.updateConfigAction({
25
+ namespace: 'openpeeps',
26
+ name: 'community',
27
+ });
28
+ const [custom, setCustom] = useState<string[]>([]);
29
+ const [draft, setDraft] = useState('');
30
+ const [fieldError, setFieldError] = useState<string | null>(null);
31
+ const [saving, setSaving] = useState(false);
32
+ const [status, setStatus] = useState<{
33
+ type: 'success' | 'error';
34
+ message: string;
35
+ } | null>(null);
36
+
37
+ useSetPageHeader(
38
+ t('configuration.community.forbiddenUsernames.title', {
39
+ defaultValue: 'Forbidden usernames',
40
+ }),
41
+ );
42
+
43
+ const base = configQuery.data?.config as CommunityConfig | undefined;
44
+ const saved = collectAdditionalForbiddenHandles(
45
+ base?.settings?.additionalForbiddenHandles ?? [],
46
+ ).handles;
47
+ const savedKey = saved.join('\n');
48
+
49
+ useEffect(() => {
50
+ setCustom(savedKey ? savedKey.split('\n') : []);
51
+ }, [savedKey]);
52
+
53
+ const issueMessage = (
54
+ issue: NonNullable<ReturnType<typeof classifyAdditionalForbiddenHandle>>,
55
+ ) => {
56
+ if (issue === 'empty') {
57
+ return t('configuration.community.forbiddenUsernames.empty', {
58
+ defaultValue: 'Enter a username to add.',
59
+ });
60
+ }
61
+ if (issue === 'invalid') {
62
+ return t('configuration.community.forbiddenUsernames.invalid', {
63
+ defaultValue:
64
+ 'Usernames must be 1–16 characters: letters, numbers, underscores, or hyphens.',
65
+ });
66
+ }
67
+ if (issue === 'builtIn') {
68
+ return t('configuration.community.forbiddenUsernames.builtInError', {
69
+ defaultValue:
70
+ 'Built-in usernames are always reserved and cannot be changed.',
71
+ });
72
+ }
73
+ return t('configuration.community.forbiddenUsernames.duplicate', {
74
+ defaultValue: 'That username is already on the list.',
75
+ });
76
+ };
77
+
78
+ const addUsername = () => {
79
+ const issue = classifyAdditionalForbiddenHandle(draft, custom);
80
+ if (issue) {
81
+ setFieldError(issueMessage(issue));
82
+ return;
83
+ }
84
+ setCustom((prev) => [...prev, normalizeForbiddenHandle(draft)]);
85
+ setDraft('');
86
+ setFieldError(null);
87
+ };
88
+
89
+ const save = async () => {
90
+ setStatus(null);
91
+ setSaving(true);
92
+ try {
93
+ await updateConfig({
94
+ config: { settings: { additionalForbiddenHandles: custom } },
95
+ });
96
+ setStatus({
97
+ type: 'success',
98
+ message: t('configuration.community.updateSuccess', {
99
+ defaultValue: 'Community settings updated',
100
+ }),
101
+ });
102
+ } catch (err) {
103
+ setStatus({ type: 'error', message: (err as Error).message });
104
+ } finally {
105
+ setSaving(false);
106
+ }
107
+ };
108
+
109
+ if (configQuery.isLoading) {
110
+ return (
111
+ <div className="text-muted-foreground flex h-32 items-center justify-center text-sm">
112
+ {t('common.form.loading', { defaultValue: 'Loading…' })}
113
+ </div>
114
+ );
115
+ }
116
+
117
+ return (
118
+ <div
119
+ className="flex flex-col gap-4 p-4"
120
+ data-testid="admin-forbidden-usernames"
121
+ >
122
+ <p className="text-muted-foreground text-sm">
123
+ {t('configuration.community.forbiddenUsernames.description', {
124
+ defaultValue:
125
+ 'Block usernames your community does not allow, such as slurs or hate speech. Each entry is a full username, ignoring capitalization. Built-in usernames stay reserved and cannot be removed.',
126
+ })}
127
+ </p>
128
+ <ul className="border-border divide-border divide-y border">
129
+ {forbiddenHandles.map((handle) => (
130
+ <li
131
+ key={handle}
132
+ className="flex items-center justify-between gap-3 px-3 py-2"
133
+ data-testid={`admin-forbidden-username-${handle}`}
134
+ >
135
+ <span>{handle}</span>
136
+ <span className="text-muted-foreground flex items-center gap-1 text-xs">
137
+ <Lock className="size-3" aria-hidden="true" />
138
+ {t('configuration.community.forbiddenUsernames.builtIn', {
139
+ defaultValue: 'Built-in',
140
+ })}
141
+ </span>
142
+ </li>
143
+ ))}
144
+ {custom.map((handle) => (
145
+ <li
146
+ key={handle}
147
+ className="flex items-center justify-between gap-3 px-3 py-2"
148
+ data-testid={`admin-forbidden-username-${handle}`}
149
+ >
150
+ <span>{handle}</span>
151
+ <Button
152
+ variant="ghost"
153
+ title={t('configuration.community.forbiddenUsernames.remove', {
154
+ defaultValue: 'Remove',
155
+ })}
156
+ action={() =>
157
+ setCustom((prev) => prev.filter((item) => item !== handle))
158
+ }
159
+ data-testid={`admin-forbidden-username-remove-${handle}`}
160
+ >
161
+ <X className="size-4" aria-hidden="true" />
162
+ {t('configuration.community.forbiddenUsernames.remove', {
163
+ defaultValue: 'Remove',
164
+ })}
165
+ </Button>
166
+ </li>
167
+ ))}
168
+ </ul>
169
+ <div className="flex flex-col gap-2">
170
+ <div className="flex flex-wrap items-center gap-2">
171
+ <Input
172
+ value={draft}
173
+ placeholder={t(
174
+ 'configuration.community.forbiddenUsernames.placeholder',
175
+ { defaultValue: 'username' },
176
+ )}
177
+ aria-invalid={Boolean(fieldError)}
178
+ onChange={(event) => {
179
+ setDraft(event.target.value);
180
+ setFieldError(null);
181
+ }}
182
+ onKeyDown={(event) => {
183
+ if (event.key !== 'Enter') return;
184
+ event.preventDefault();
185
+ addUsername();
186
+ }}
187
+ data-testid="admin-forbidden-usernames-input"
188
+ />
189
+ <Button
190
+ variant="outline"
191
+ title={t('configuration.community.forbiddenUsernames.add', {
192
+ defaultValue: 'Add username',
193
+ })}
194
+ action={addUsername}
195
+ data-testid="admin-forbidden-usernames-add"
196
+ >
197
+ {t('configuration.community.forbiddenUsernames.add', {
198
+ defaultValue: 'Add username',
199
+ })}
200
+ </Button>
201
+ </div>
202
+ {fieldError ? (
203
+ <p className="text-error text-sm" role="alert">
204
+ {fieldError}
205
+ </p>
206
+ ) : null}
207
+ </div>
208
+ {status ? (
209
+ <Toast variant={status.type} onDismiss={() => setStatus(null)}>
210
+ {status.message}
211
+ </Toast>
212
+ ) : null}
213
+ <Button
214
+ variant="default"
215
+ action={save}
216
+ disabled={saving || sameHandles(custom, saved)}
217
+ data-testid="admin-forbidden-usernames-save"
218
+ >
219
+ {t('common.form.save', { defaultValue: 'Save' })}
220
+ </Button>
221
+ </div>
222
+ );
223
+ }
@@ -13,8 +13,8 @@ import { roleKeyFromName } from '../../../lib/capabilityMatrix';
13
13
  const TAB_DEFAULT_ROLE = 'default-role';
14
14
  const TAB_ROLES = 'roles';
15
15
  const TAB_RELATIONS = 'relations';
16
- const TAB_LIST = [TAB_DEFAULT_ROLE, TAB_ROLES, TAB_RELATIONS] as const;
17
- type TabKey = (typeof TAB_LIST)[number];
16
+ const _TAB_LIST = [TAB_DEFAULT_ROLE, TAB_ROLES, TAB_RELATIONS] as const;
17
+ type TabKey = (typeof _TAB_LIST)[number];
18
18
 
19
19
  function DefaultRoles({ base }: { base: CommunityConfig }) {
20
20
  const t = useT();
@@ -0,0 +1,263 @@
1
+ import { useState } from 'react';
2
+ import type { InviteLinkWithMeta } from '@openpeepshq/common/types';
3
+ import { useOpenpeeps, useT } from '../../../index';
4
+ import {
5
+ Dialog,
6
+ DialogActions,
7
+ DialogContent,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ Input,
11
+ Label,
12
+ } from '@openpeepshq/react-ui';
13
+ import { DAY_MS, EXPIRY_OPTIONS, UNLIMITED_USES } from './InviteWithLinkModal';
14
+
15
+ const NEVER_DAYS =
16
+ EXPIRY_OPTIONS.find((option) => option.value === 'P100Y')?.days ?? 365 * 100;
17
+
18
+ const FAR_FUTURE_MS = 50 * 365 * DAY_MS;
19
+
20
+ const pad = (value: number) => String(value).padStart(2, '0');
21
+
22
+ const toDatetimeLocal = (iso: string) => {
23
+ const date = new Date(iso);
24
+ if (Number.isNaN(date.getTime())) return '';
25
+ const day = [
26
+ date.getFullYear(),
27
+ pad(date.getMonth() + 1),
28
+ pad(date.getDate()),
29
+ ].join('-');
30
+ const time = [pad(date.getHours()), pad(date.getMinutes())].join(':');
31
+ return `${day}T${time}`;
32
+ };
33
+
34
+ const isFarFuture = (iso: string) =>
35
+ new Date(iso).getTime() - Date.now() > FAR_FUTURE_MS;
36
+
37
+ const useChoices = (invite: InviteLinkWithMeta) => {
38
+ const floor = Math.max(invite.redemptions.length, 1);
39
+ const current = invite.maxUses < UNLIMITED_USES ? [invite.maxUses] : [];
40
+ return [...new Set([1, 5, 10, 15, 20, ...current])]
41
+ .filter((count) => count >= floor)
42
+ .sort((a, b) => a - b);
43
+ };
44
+
45
+ const initialUses = (invite: InviteLinkWithMeta) => {
46
+ if (
47
+ invite.maxUses >= UNLIMITED_USES ||
48
+ invite.maxUses < invite.redemptions.length
49
+ ) {
50
+ return 'unlimited';
51
+ }
52
+ return String(invite.maxUses);
53
+ };
54
+
55
+ const errorMessage = (err: unknown, fallback: string) => {
56
+ if (
57
+ err &&
58
+ typeof err === 'object' &&
59
+ 'message' in err &&
60
+ typeof err.message === 'string' &&
61
+ err.message
62
+ ) {
63
+ return err.message;
64
+ }
65
+ return fallback;
66
+ };
67
+
68
+ export const EditInviteLinkModal = ({
69
+ invite,
70
+ onClose,
71
+ }: {
72
+ invite: InviteLinkWithMeta;
73
+ onClose: () => void;
74
+ }) => {
75
+ const t = useT();
76
+ const { openpeepsApi } = useOpenpeeps();
77
+ const updateInvite = openpeepsApi.admin.updateInviteAction({
78
+ id: invite.id,
79
+ });
80
+ const used = invite.redemptions.length;
81
+ const choices = useChoices(invite);
82
+ const startsNever = isFarFuture(invite.expiresAt);
83
+
84
+ const [maxUses, setMaxUses] = useState(() => initialUses(invite));
85
+ const [never, setNever] = useState(startsNever);
86
+ const [expiresLocal, setExpiresLocal] = useState(() =>
87
+ toDatetimeLocal(
88
+ startsNever
89
+ ? new Date(Date.now() + 7 * DAY_MS).toISOString()
90
+ : invite.expiresAt,
91
+ ),
92
+ );
93
+ const [submitting, setSubmitting] = useState(false);
94
+ const [error, setError] = useState<string | null>(null);
95
+
96
+ const parsedExpiry = new Date(expiresLocal);
97
+ const expiresInPast =
98
+ !never &&
99
+ expiresLocal !== '' &&
100
+ !Number.isNaN(parsedExpiry.getTime()) &&
101
+ parsedExpiry.getTime() <= Date.now();
102
+
103
+ const submit = async () => {
104
+ setError(null);
105
+ const unlimited = maxUses === 'unlimited';
106
+ const nextMaxUses = unlimited ? UNLIMITED_USES : Number(maxUses);
107
+ if (!unlimited && (!Number.isInteger(nextMaxUses) || nextMaxUses < used)) {
108
+ setError(
109
+ t('admin.invites.maxUsesTooLow', {
110
+ defaultValue:
111
+ 'Number of uses cannot be lower than {{count}}, the number of accounts that already joined.',
112
+ count: used,
113
+ }),
114
+ );
115
+ return;
116
+ }
117
+
118
+ const patch: { maxUses?: number; expiresAt?: string } = {};
119
+ if (nextMaxUses !== invite.maxUses) patch.maxUses = nextMaxUses;
120
+
121
+ if (never) {
122
+ if (!startsNever) {
123
+ patch.expiresAt = new Date(
124
+ Date.now() + NEVER_DAYS * DAY_MS,
125
+ ).toISOString();
126
+ }
127
+ } else if (toDatetimeLocal(invite.expiresAt) !== expiresLocal) {
128
+ if (!expiresLocal || Number.isNaN(parsedExpiry.getTime())) {
129
+ setError(
130
+ t('admin.invites.expiresRequired', {
131
+ defaultValue: 'Choose an expiration date.',
132
+ }),
133
+ );
134
+ return;
135
+ }
136
+ patch.expiresAt = parsedExpiry.toISOString();
137
+ }
138
+
139
+ if (patch.maxUses == null && patch.expiresAt == null) {
140
+ onClose();
141
+ return;
142
+ }
143
+
144
+ setSubmitting(true);
145
+ try {
146
+ await updateInvite(patch);
147
+ onClose();
148
+ } catch (err) {
149
+ setError(
150
+ errorMessage(
151
+ err,
152
+ t('admin.invites.updateError', {
153
+ defaultValue: 'Failed to update invite link',
154
+ }),
155
+ ),
156
+ );
157
+ } finally {
158
+ setSubmitting(false);
159
+ }
160
+ };
161
+
162
+ return (
163
+ <Dialog open onOpenChange={(open) => !open && onClose()}>
164
+ <DialogContent className="max-w-md" data-testid="edit-invite-link">
165
+ <DialogHeader>
166
+ <DialogTitle>
167
+ {t('admin.invites.editTitle', {
168
+ defaultValue: 'Edit invite link',
169
+ })}
170
+ </DialogTitle>
171
+ </DialogHeader>
172
+ <div className="space-y-4 px-1">
173
+ <p className="text-muted-foreground text-sm">
174
+ {t('admin.invites.editDescription', {
175
+ defaultValue:
176
+ 'Update how many times this link can be used, or when it expires.',
177
+ })}
178
+ </p>
179
+ <p className="font-mono text-xs">{invite.slug}</p>
180
+ <div className="space-y-2">
181
+ <Label htmlFor="edit-invite-uses">
182
+ {t('admin.inviteLink.numberOfUses', {
183
+ defaultValue: 'Number of Uses',
184
+ })}
185
+ </Label>
186
+ <select
187
+ id="edit-invite-uses"
188
+ className="border-input bg-background w-full rounded-md border p-2 text-sm"
189
+ value={maxUses}
190
+ onChange={(e) => setMaxUses(e.target.value)}
191
+ >
192
+ {choices.map((count) => (
193
+ <option key={count} value={String(count)}>
194
+ {count}
195
+ </option>
196
+ ))}
197
+ <option value="unlimited">
198
+ {t('admin.inviteLink.unlimited', {
199
+ defaultValue: 'Unlimited',
200
+ })}
201
+ </option>
202
+ </select>
203
+ {used > 0 ? (
204
+ <p className="text-muted-foreground text-xs">
205
+ {t('admin.invites.alreadyJoined', {
206
+ defaultValue: 'Already joined: {{count}}',
207
+ count: used,
208
+ })}
209
+ </p>
210
+ ) : null}
211
+ </div>
212
+ <div className="space-y-2">
213
+ <Label htmlFor="edit-invite-expiry">
214
+ {t('admin.invites.expirationDate', {
215
+ defaultValue: 'Expiration date',
216
+ })}
217
+ </Label>
218
+ <Input
219
+ id="edit-invite-expiry"
220
+ type="datetime-local"
221
+ value={expiresLocal}
222
+ disabled={never}
223
+ onChange={(e) => setExpiresLocal(e.target.value)}
224
+ />
225
+ <label className="flex items-center gap-2 text-sm">
226
+ <input
227
+ type="checkbox"
228
+ className="size-4"
229
+ checked={never}
230
+ onChange={(e) => setNever(e.target.checked)}
231
+ />
232
+ <span>
233
+ {t('admin.invites.neverExpires', {
234
+ defaultValue: 'Never expires',
235
+ })}
236
+ </span>
237
+ </label>
238
+ {expiresInPast ? (
239
+ <p className="text-muted-foreground text-xs">
240
+ {t('admin.invites.pastExpiration', {
241
+ defaultValue:
242
+ 'This date is in the past, so the link will be inactive.',
243
+ })}
244
+ </p>
245
+ ) : null}
246
+ </div>
247
+ {error ? (
248
+ <p className="border-error/40 text-error rounded-md border p-2 text-sm">
249
+ {error}
250
+ </p>
251
+ ) : null}
252
+ </div>
253
+ <DialogActions
254
+ cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
255
+ onCancel={onClose}
256
+ actionLabel={t('common.save', { defaultValue: 'Save' })}
257
+ onAction={submit}
258
+ disabled={submitting}
259
+ />
260
+ </DialogContent>
261
+ </Dialog>
262
+ );
263
+ };
@@ -8,6 +8,9 @@ import { Eye, EyeOff } from 'lucide-react';
8
8
  import { useForm } from 'react-hook-form';
9
9
  import { zodResolver } from '@hookform/resolvers/zod';
10
10
  import {
11
+ accountNameSchema,
12
+ HANDLE_RESERVED_MESSAGE,
13
+ isForbiddenHandle,
11
14
  registerRequestSchema,
12
15
  type RegisterRequest,
13
16
  } from '@openpeepshq/common/types';
@@ -43,7 +46,10 @@ const INVITE_INACTIVE_MESSAGES = new Set([
43
46
  'Invalid Invite Code',
44
47
  ]);
45
48
 
46
- const buildRegisterFormSchema = (t: TFunction) =>
49
+ const buildRegisterFormSchema = (
50
+ t: TFunction,
51
+ additionalForbiddenHandles: readonly string[] = [],
52
+ ) =>
47
53
  registerRequestSchema
48
54
  .refine((d) => d.password === d.confirmPassword, {
49
55
  message: t('auth.register.passwordsDoNotMatch', {
@@ -56,14 +62,32 @@ const buildRegisterFormSchema = (t: TFunction) =>
56
62
  defaultValue: 'You must agree to the privacy policy',
57
63
  }),
58
64
  path: ['privacyPolicyAccepted'],
65
+ })
66
+ .superRefine((data, ctx) => {
67
+ if (!isForbiddenHandle(data.handle, additionalForbiddenHandles)) return;
68
+ // Built-in names already fail accountNameSchema.
69
+ if (!accountNameSchema.safeParse(data.handle).success) return;
70
+ ctx.addIssue({
71
+ code: 'custom',
72
+ path: ['handle'],
73
+ message: t('profile.form.handleReserved', {
74
+ defaultValue: 'That handle is reserved. Please choose another.',
75
+ }),
76
+ });
59
77
  });
60
78
 
61
- const registerErrorCopy = (raw: string, t: TFunction) =>
62
- INVITE_INACTIVE_MESSAGES.has(raw)
79
+ const registerErrorCopy = (raw: string, t: TFunction) => {
80
+ if (raw === HANDLE_RESERVED_MESSAGE) {
81
+ return t('profile.form.handleReserved', {
82
+ defaultValue: 'That handle is reserved. Please choose another.',
83
+ });
84
+ }
85
+ return INVITE_INACTIVE_MESSAGES.has(raw)
63
86
  ? t('auth.register.inviteInactive', {
64
87
  defaultValue: 'This invite link is expired or no longer active.',
65
88
  })
66
89
  : t(raw);
90
+ };
67
91
 
68
92
  export function Register({ invite = false }: RegisterProps) {
69
93
  const t = useT();
@@ -75,7 +99,12 @@ export function Register({ invite = false }: RegisterProps) {
75
99
  const serverInfo = useServerInfo();
76
100
  const { success, error: toastError } = useToast();
77
101
 
78
- const registerFormSchema = useMemo(() => buildRegisterFormSchema(t), [t]);
102
+ const additionalForbiddenHandles =
103
+ serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
104
+ const registerFormSchema = useMemo(
105
+ () => buildRegisterFormSchema(t, additionalForbiddenHandles ?? []),
106
+ [t, additionalForbiddenHandles],
107
+ );
79
108
 
80
109
  const paymentParam = searchParams.get('payment');
81
110
  useEffect(() => {
@@ -139,6 +139,17 @@ export function ConversationShow() {
139
139
  };
140
140
  }, [id, client, queryClient, flushPostViews]);
141
141
 
142
+ // The URL may point at any root of a merged 1:1 conversation (e.g.
143
+ // notification links); unseen counts are merged under the pair's oldest
144
+ // root, so clear that key once the conversation's first message is known.
145
+ const firstMessageId = messages[0]?.id;
146
+ useEffect(() => {
147
+ if (!id || !firstMessageId || firstMessageId === id) return;
148
+ adjustUnseenCounts(queryClient, client, {
149
+ clearConversation: firstMessageId,
150
+ });
151
+ }, [id, firstMessageId, client, queryClient]);
152
+
142
153
  useEffect(() => {
143
154
  if (!id || !me || conversationQuery.isLoading) return;
144
155
  const unseenIds = messages
@@ -57,6 +57,7 @@ export { AnalyticsGroupsPage } from './admin/Analytics';
57
57
  export { AnalyticsPluginPage } from './admin/Analytics';
58
58
  export { AnalyticsReportSettingsPage } from './admin/Analytics';
59
59
  export { AdminBackups } from './admin/Backups';
60
+ export { AdminMedia } from './admin/Media';
60
61
  export { AdminGroups } from './admin/Groups';
61
62
  export { AdminInvites } from './admin/Invites';
62
63
  export { AdminMembers } from './admin/Members';
@@ -82,6 +83,7 @@ export { CommunityMarkdownPage } from './admin/community/CommunityMarkdownPage';
82
83
  export { AdminConfigurationCommunityFavicons } from './admin/community/CommunityFavicons';
83
84
  export { AdminConfigurationCommunityTheme } from './admin/community/CommunityTheme';
84
85
  export { AdminConfigurationCommunityProfileFields } from './admin/community/CommunityProfileFields';
86
+ export { AdminConfigurationCommunityForbiddenUsernames } from './admin/community/CommunityForbiddenUsernames';
85
87
  export { AdminConfigurationCommunityRoles } from './admin/community/CommunityRoles';
86
88
  export { AdminGroupMembers } from './admin/GroupMembers';
87
89
  export { AdminReports } from './admin/Reports';
@@ -89,6 +91,7 @@ export { AdminApiKeys } from './admin/ApiKeys';
89
91
  export { AdminPlugins } from './admin/Plugins';
90
92
  export { AdminDiagnostics } from './admin/Diagnostics';
91
93
  export { AdminDiagnosticsEmail } from './admin/DiagnosticsEmail';
94
+ export { AdminDiagnosticsLivekit } from './admin/DiagnosticsLivekit';
92
95
  export { AdminDiagnosticsLogs } from './admin/DiagnosticsLogs';
93
96
  export { AdminConfigurationEmail } from './admin/ConfigurationEmail';
94
97
  export { AdminConfigurationSso } from './admin/ConfigurationSso';
@@ -10,6 +10,7 @@ import {
10
10
  import {
11
11
  EventsFeed,
12
12
  LiveJamsSection,
13
+ LivekitUnavailableNotice,
13
14
  useCreateNewJam,
14
15
  useServerInfo,
15
16
  } from '../../components';
@@ -77,12 +78,7 @@ export function JamsIndex({ my = false }: Props) {
77
78
  return (
78
79
  <div className="p-4">
79
80
  {!serverInfo.jams.livekit.enabled ? (
80
- <p role="status" className="text-destructive mb-4 text-sm">
81
- {t('jams.unavailable.message', {
82
- defaultValue:
83
- 'Jams are unavailable because LiveKit is not connected.',
84
- })}
85
- </p>
81
+ <LivekitUnavailableNotice className="text-destructive mb-4 text-sm" />
86
82
  ) : null}
87
83
  {!my && serverInfo.jams.livekit.enabled ? <LiveJamsSection /> : null}
88
84
 
@@ -2,6 +2,8 @@ import { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import type { ProfileWithMeta } from '@openpeepshq/common/types';
3
3
  import {
4
4
  accountNameSchema,
5
+ HANDLE_RESERVED_MESSAGE,
6
+ isForbiddenHandle,
5
7
  profileDataSchema,
6
8
  } from '@openpeepshq/common/types';
7
9
  import { useT, useOpenpeeps, useSetPageHeader } from '../../index';
@@ -62,11 +64,19 @@ export function PublicProfileSettings() {
62
64
 
63
65
  if (!me) return null;
64
66
 
67
+ const additionalForbiddenHandles =
68
+ serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
69
+
65
70
  const validateHandle = (value: string): string | null => {
71
+ if (isForbiddenHandle(value, additionalForbiddenHandles)) {
72
+ return t('profile.form.handleReserved', {
73
+ defaultValue: 'That handle is reserved. Please choose another.',
74
+ });
75
+ }
66
76
  const result = accountNameSchema.safeParse(value);
67
77
  if (result.success) return null;
68
78
  const message = firstZodMessage(result.error);
69
- if (message === 'Handle is reserved') {
79
+ if (message === HANDLE_RESERVED_MESSAGE) {
70
80
  return t('profile.form.handleReserved', {
71
81
  defaultValue: 'That handle is reserved. Please choose another.',
72
82
  });
@@ -115,7 +125,7 @@ export function PublicProfileSettings() {
115
125
  const message = firstZodMessage(err);
116
126
  if (message?.toLowerCase().includes('handle')) {
117
127
  setHandleError(
118
- message === 'Handle is reserved'
128
+ message === HANDLE_RESERVED_MESSAGE
119
129
  ? t('profile.form.handleReserved', {
120
130
  defaultValue:
121
131
  'That handle is reserved. Please choose another.',
@@ -128,6 +138,14 @@ export function PublicProfileSettings() {
128
138
  return;
129
139
  }
130
140
  }
141
+ if ((err as Error).message === HANDLE_RESERVED_MESSAGE) {
142
+ setHandleError(
143
+ t('profile.form.handleReserved', {
144
+ defaultValue: 'That handle is reserved. Please choose another.',
145
+ }),
146
+ );
147
+ return;
148
+ }
131
149
  if (isDuplicateHandleError(err)) {
132
150
  const msg = t('profiles.handleExists', {
133
151
  defaultValue: 'This handle is already in use by someone else.',