Shaharyar
Shaharyar

Reputation: 12449

Delete post with all its notifications and feed

Scenario:

user:1 created a post:

{ actor: 'user:1', verb: 'POST_CREATE', object: 'post:1', foreign_id: 'post:1' }

Now, user:1 is followed by user:2, user:3 and user:4. They all got this post in their feed. They did following actions on the post:

user:2 commented on it (user:1 got notification using TO field):

{ actor: 'user:2', verb: 'POST_COMMENT', object: 'comment:1', target: 'post:1', foreign_id: 'comment:1' 
TO: ['notification:1']}

user:3 and user:4 liked:

{ actor: 'user:3', verb: 'POST_LIKE', object: 'like:1', target: 'post:1', foreign_id: 'like:1' 
TO: ['notification:1', 'notification:2']}

{ actor: 'user:4', verb: 'POST_LIKE', object: 'like:2', target: 'post:1', foreign_id: 'like:2' 
TO: ['notification:1', 'notification:2', 'notification:3']}

Question:

Now when user:1 deletes the post, how would I delete all of its activities along with their references in feed and notifications? I want to do it with 1 API call.

If I need to change the activity data, please tell me.

PS:

Upvotes: 3

Views: 344

Answers (1)

iandouglas
iandouglas

Reputation: 4306

If you delete the activity (using the foreign_id) from user 1's feed where the activity was originally added, the delete will propagate to all following feeds.

For example, user 1 adds an activity and it shows up in the feeds for users 2, 3 and 4. if you tried to delete the activity from user 2's feed, for example, it would only delete the activity from that user, not everyone else.

The same will happen with updates. You update the original activity and it will propagate down-stream to following feeds. Updates must have the original foreign_id and time fields though, you cannot change those.

Upvotes: 2

Related Questions