@openpeepshq/core 0.4.0 → 0.4.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/posts/mutations.js +15 -2
- package/package.json +3 -3
package/dist/posts/mutations.js
CHANGED
|
@@ -14,7 +14,7 @@ import { findOrCreateHashtag } from '../hashtags/index.js';
|
|
|
14
14
|
import { hub } from '../events/index.js';
|
|
15
15
|
import { listUnseenGroupPostIds } from './unseenCounts.js';
|
|
16
16
|
import { AP_LIKE_REACTION, canManageEventRsvps, capacityRsvpDecision, eventDataForDbUpdate, getEffectiveRsvp, instanceRsvpIdsForProfile, isOneToOneDm, normalizeEventDataForSave, overlaySeriesRsvpEntries, participantIds, passThroughUndefined, rsvpCancelNotice, rsvpTargetsPastEvent, sameRecurrenceId, } from '@openpeepshq/common/lib';
|
|
17
|
-
import { forbidden, unprocessableRequest } from '../errors/index.js';
|
|
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';
|
|
20
20
|
import { cancelPollEnd, schedulePollEnd } from './pollEndJobs.js';
|
|
@@ -33,6 +33,11 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
33
33
|
const repliedToPost = relations.inReplyToId
|
|
34
34
|
? await postsMapping.find(db, relations.inReplyToId)
|
|
35
35
|
: undefined;
|
|
36
|
+
// A reply to a deleted post must be rejected; silently dropping the link
|
|
37
|
+
// would republish it as a top-level post on the community feed.
|
|
38
|
+
if (relations.inReplyToId && !repliedToPost) {
|
|
39
|
+
throw notFound({ errorKey: 'error.postDeleted' });
|
|
40
|
+
}
|
|
36
41
|
if (repliedToPost) {
|
|
37
42
|
postData.visibility = repliedToPost.visibility;
|
|
38
43
|
}
|
|
@@ -71,7 +76,15 @@ export const createPost = async (data, profile, postData, relations = {}) => {
|
|
|
71
76
|
data,
|
|
72
77
|
});
|
|
73
78
|
if (repliedToPost) {
|
|
74
|
-
|
|
79
|
+
// The guard above ran before several awaits; re-check so a concurrent
|
|
80
|
+
// delete cannot leave this reply attached to a tombstoned parent.
|
|
81
|
+
const liveParent = await postsMapping.find(db, repliedToPost.id);
|
|
82
|
+
if (!liveParent) {
|
|
83
|
+
const stored = await postsMapping.find(db, post.id);
|
|
84
|
+
await deletePost(await transformPost(stored), profile);
|
|
85
|
+
throw notFound({ errorKey: 'error.postDeleted' });
|
|
86
|
+
}
|
|
87
|
+
await replyConnector(db, post, liveParent);
|
|
75
88
|
await bumpConversationActivity(db, post.id);
|
|
76
89
|
}
|
|
77
90
|
if (group) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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.5.0",
|
|
41
|
-
"@openpeepshq/geocoder": "^0.1.2",
|
|
42
41
|
"@openpeepshq/fetch-client": "^0.2.1",
|
|
43
|
-
"@openpeepshq/
|
|
42
|
+
"@openpeepshq/geocoder": "^0.1.2",
|
|
43
|
+
"@openpeepshq/i18n": "^0.4.1"
|
|
44
44
|
},
|
|
45
45
|
"main": "dist/index.js",
|
|
46
46
|
"types": "dist/index.d.ts",
|