@openpeepshq/core 0.28.0 → 0.28.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.
- package/dist/jams/mutations.d.ts +12 -0
- package/dist/jams/mutations.js +38 -0
- package/package.json +3 -3
package/dist/jams/mutations.d.ts
CHANGED
|
@@ -40,3 +40,15 @@ export declare const updateJamRecording: (recordingId: string, recording: Partia
|
|
|
40
40
|
_from: string;
|
|
41
41
|
_to: string;
|
|
42
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Soft-deletes a jam chat message and blanks its content.
|
|
45
|
+
*
|
|
46
|
+
* Only the jam host, a jam moderator, or the message author may delete. The
|
|
47
|
+
* `deletedAt` soft-delete flag is what hides the row from every consumer
|
|
48
|
+
* (`listJamEvents`, attendance, export) — those all go through the
|
|
49
|
+
* soft-delete-filtered mappings; blanking `content` is belt-and-braces so no
|
|
50
|
+
* path that bypasses the flag can resurrect the text. `jamId` and `type` are
|
|
51
|
+
* re-checked server-side so an id pointing at a different jam or a non-message
|
|
52
|
+
* event (join/leave/start/…) is a 404, never a cross-jam write.
|
|
53
|
+
*/
|
|
54
|
+
export declare const deleteJamEvent: (actorId: string, jamId: string, jamEventId: string) => Promise<boolean>;
|
package/dist/jams/mutations.js
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
|
+
import { jamFromEvent } from '@openpeepshq/common/lib';
|
|
2
|
+
import { forbidden, notFound } from '../errors/index.js';
|
|
1
3
|
import { allpeepDb } from '../db/index.js';
|
|
4
|
+
import { findPost } from '../posts/index.js';
|
|
2
5
|
import { jamEventsMapping, jamRecordingsMapping } from './mapping.js';
|
|
3
6
|
export const createJamEvent = (jamEvent) => allpeepDb().then(({ db }) => jamEventsMapping.create(db, jamEvent));
|
|
4
7
|
export const updateJamRecording = (recordingId, recording) => allpeepDb().then(({ db }) => jamRecordingsMapping.update(db, recordingId, recording));
|
|
8
|
+
/**
|
|
9
|
+
* Soft-deletes a jam chat message and blanks its content.
|
|
10
|
+
*
|
|
11
|
+
* Only the jam host, a jam moderator, or the message author may delete. The
|
|
12
|
+
* `deletedAt` soft-delete flag is what hides the row from every consumer
|
|
13
|
+
* (`listJamEvents`, attendance, export) — those all go through the
|
|
14
|
+
* soft-delete-filtered mappings; blanking `content` is belt-and-braces so no
|
|
15
|
+
* path that bypasses the flag can resurrect the text. `jamId` and `type` are
|
|
16
|
+
* re-checked server-side so an id pointing at a different jam or a non-message
|
|
17
|
+
* event (join/leave/start/…) is a 404, never a cross-jam write.
|
|
18
|
+
*/
|
|
19
|
+
export const deleteJamEvent = async (actorId, jamId, jamEventId) => {
|
|
20
|
+
const { db } = await allpeepDb();
|
|
21
|
+
// ignoreSoftDelete: a re-delete must be a no-op 404, not a re-mutation.
|
|
22
|
+
const jamEvent = await jamEventsMapping.find(db, jamEventId, {
|
|
23
|
+
ignoreSoftDelete: true,
|
|
24
|
+
});
|
|
25
|
+
if (!jamEvent || jamEvent.jamId !== jamId || jamEvent.type !== 'message') {
|
|
26
|
+
throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
|
|
27
|
+
}
|
|
28
|
+
const jamPost = await findPost(jamId);
|
|
29
|
+
const jam = jamPost ? jamFromEvent(jamPost) : undefined;
|
|
30
|
+
if (!jamPost || !jam) {
|
|
31
|
+
throw notFound({ errorKey: 'error.jamNotFound', parameters: { jamId } });
|
|
32
|
+
}
|
|
33
|
+
const isHost = jamPost.profile.id === actorId;
|
|
34
|
+
const isModerator = jam.moderators?.includes(actorId) ?? false;
|
|
35
|
+
const isAuthor = jamEvent.profileId === actorId;
|
|
36
|
+
if (!isHost && !isModerator && !isAuthor) {
|
|
37
|
+
throw forbidden({ errorKey: 'error.forbidden' });
|
|
38
|
+
}
|
|
39
|
+
await jamEventsMapping.update(db, jamEventId, { content: '' });
|
|
40
|
+
await jamEventsMapping.delete(db, jamEventId);
|
|
41
|
+
return true;
|
|
42
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/core",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"dependencies": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"uuidv7": "^1.0.2",
|
|
39
39
|
"web-push": "^3.6.7",
|
|
40
40
|
"@openpeepshq/common": "0.30.0",
|
|
41
|
-
"@openpeepshq/
|
|
41
|
+
"@openpeepshq/i18n": "^0.31.1",
|
|
42
42
|
"@openpeepshq/geocoder": "^0.1.2",
|
|
43
|
-
"@openpeepshq/
|
|
43
|
+
"@openpeepshq/fetch-client": "^0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"main": "dist/index.js",
|
|
46
46
|
"types": "dist/index.d.ts",
|