@fabriktor/fx 0.0.162 → 0.0.164
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/src/feed/feed.d.ts +0 -1
- package/dist/src/feed/feed.js +9 -7
- package/package.json +1 -1
package/dist/src/feed/feed.d.ts
CHANGED
package/dist/src/feed/feed.js
CHANGED
|
@@ -371,19 +371,21 @@ export class FeedFX {
|
|
|
371
371
|
async addReaction(opts) {
|
|
372
372
|
const post_id = feedPostID(opts.post);
|
|
373
373
|
return await this.runAction(post_id, FeedAction.Reaction, async (signal) => {
|
|
374
|
-
const fresh = await this.requireFeedPost(post_id, signal);
|
|
375
|
-
const id = resolvedID(fresh.self.reaction_id);
|
|
376
|
-
if (id && !opts.replace_existing)
|
|
377
|
-
throw errValidation({
|
|
378
|
-
msg: "An action already exists for this post.",
|
|
379
|
-
});
|
|
380
374
|
if (![FeedLike, FeedDislike, FeedReport].includes(opts.reaction_type))
|
|
381
375
|
throw errValidation({
|
|
382
376
|
field: "reaction_type",
|
|
383
377
|
msg: "Unsupported reaction.",
|
|
384
378
|
});
|
|
379
|
+
const fresh = await this.requireFeedPost(post_id, signal);
|
|
380
|
+
const id = resolvedID(fresh.self.reaction_id);
|
|
385
381
|
if (id) {
|
|
386
|
-
await this.
|
|
382
|
+
const current = await this.readOwnReaction({ id, signal });
|
|
383
|
+
if (!current)
|
|
384
|
+
throw errValidation({ msg: msgFeedReactionMissing });
|
|
385
|
+
if (current.reaction_type === opts.reaction_type ||
|
|
386
|
+
current.reaction_type === FeedReport)
|
|
387
|
+
throw errValidation({ msg: msgFeedReactionAlreadyExists });
|
|
388
|
+
await this.feed.deleteOneFeedReaction({ id, signal });
|
|
387
389
|
signal.throwIfAborted();
|
|
388
390
|
this.markActionRemoved(post_id, FeedAction.Reaction);
|
|
389
391
|
}
|