-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Sending & Un-sending Likes #35
Conversation
const likeJson = await like.toJsonLd(); | ||
await ctx.get('globaldb').set([like.id!.href], likeJson); | ||
|
||
await addToList(ctx.get('db'), ['liked'], like.id!.href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Should this be the ID of the liked object rather than the like activity itself? Then the liked dispatcher returns the objects liked and not the like activities themselves?
Spec says:
This is a list of every object from all of the actor's Like activities, added as a [side effect]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did initially think that, but then in the liked dispatcher, fedify would error because it expects a return type of Like[]
😕
I think we need to get fedify updated (and fixed) to handle returning objects from the liked dispatcher - I'll sort that next week
refs https://linear.app/tryghost/issue/AP-292 This follows the same pattern as our other collections and calls reverse to ensure reverse chronological order. At the moment this collection contains Like activities rather than their objects, this is due to types in fedify, eventually we want to have this collection contain the liked objects rather than the Like activities
refs https://linear.app/tryghost/issue/AP-286 These are required for us to generate URL's for Like and Undo objects, which we need for the "like" and "unlike" actions.
refs https://linear.app/tryghost/issue/AP-286 We use the hash of the underlying object to generate the id of the Like activity, this allows us to easily lookup the Like activity when attempting to unlike, rather than searching for it.
refs https://linear.app/tryghost/issue/AP-293 In order to render the feed and inbox we need to know which objects have been liked, this is a naive implementation which doesn't scale to multiple users and should be replaced as party of the database restructure work.
We want to use this in multiple places!
refs https://linear.app/tryghost/issue/AP-286 We want to make sure that the original author is notified of the activity as well as our followers. This is wrapped in guards because it's possible the property doesn't exist.
🍦
We got a few things happening here!
We're adding a liked collection to actors, this is so that we can render a list of the liked content in the Admin. The liked collection functions similar to how we're doing the inbox and outbox, we're storing an array of the ids belonging to the collection.
We've got some basic object dispatchers wired up for
Like
andUndo
which is necessary so that we can generate id's for those objects.The inbox handler has been updating to attached a
liked
property to theobject
of the activity, this allows us to render the item correctly in the frontend with a filled in heart. I didn't store theliked
property on the object, because of concerns of losing the data - e.g. if we start handlingUpdate
activities and we overwrite the object in the DB - we might lose theliked
status. There's also the issue of what happens when we support multiple users, we can't store it on the object itself.Adding the
liked
property is not efficient though - and we really need to rethink storage solutions around this.And of course we have two actions "like" and "unlike" - they are fairly simple - we first check if the object we're trying to like/unlike exists, and 404 if it doesn't. Then we check if we've already performed that action, and 409 if we have. After that we construct the relevant activity, store it, and send it to our followers - we also need to send it to the original author of the object using
attributedTo