diff --git a/api/users/:uuid/inbox/index.ts b/api/users/:uuid/inbox/index.ts index bb6f89bf..ff2189cd 100644 --- a/api/users/:uuid/inbox/index.ts +++ b/api/users/:uuid/inbox/index.ts @@ -366,7 +366,7 @@ export default apiRoute((app) => // "delete" is a reserved keyword in JS delete: async (delete_) => { // Delete the specified object from database, if it exists and belongs to the user - const toDelete = delete_.target; + const toDelete = delete_.deleted; switch (delete_.deleted_type) { case "Note": { diff --git a/bun.lockb b/bun.lockb index f039f30c..bbc53a2d 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/classes/database/like.ts b/classes/database/like.ts index 631c070a..cece6c41 100644 --- a/classes/database/like.ts +++ b/classes/database/like.ts @@ -1,5 +1,5 @@ import { RolePermission } from "@versia/client/types"; -import type { LikeExtension } from "@versia/federation"; +import type { Delete, LikeExtension } from "@versia/federation/types"; import { type InferInsertModel, type InferSelectModel, @@ -160,4 +160,19 @@ export class Like extends BaseInterface { uri: this.getUri().toString(), }; } + + public unlikeToVersia(unliker?: User): Delete { + return { + type: "Delete", + id: crypto.randomUUID(), + created_at: new Date().toISOString(), + author: User.getUri( + unliker?.id ?? this.data.liker.id, + unliker?.data.uri ?? this.data.liker.uri, + config.http.base_url, + ), + deleted_type: "pub.versia:likes/Like", + deleted: this.getUri().toString(), + }; + } } diff --git a/classes/database/note.ts b/classes/database/note.ts index 4ff62963..a74cb77e 100644 --- a/classes/database/note.ts +++ b/classes/database/note.ts @@ -987,7 +987,7 @@ export class Note extends BaseInterface { id, author: this.author.getUri(), deleted_type: "Note", - target: this.getUri(), + deleted: this.getUri(), created_at: new Date().toISOString(), }; } diff --git a/classes/database/user.ts b/classes/database/user.ts index 70a9f91c..af5d8a7f 100644 --- a/classes/database/user.ts +++ b/classes/database/user.ts @@ -473,7 +473,8 @@ export class User extends BaseInterface { noteId: note.id, }); } else { - // TODO: Add database jobs for federating this + // Federate the like + this.federateToFollowers(newLike.toVersia()); } return newLike; @@ -511,7 +512,7 @@ export class User extends BaseInterface { if (this.isLocal() && note.author.isRemote()) { // User is local, federate the delete - // TODO: Federate this + this.federateToFollowers(likeToDelete.unlikeToVersia(this)); } } diff --git a/package.json b/package.json index bb68cdff..b6f9ac1a 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "@sentry/bun": "^8.35.0", "@tufjs/canonical-json": "^2.0.0", "@versia/client": "^0.1.0", - "@versia/federation": "^0.1.1", + "@versia/federation": "^0.1.2", "@versia/kit": "workspace:*", "altcha-lib": "^1.1.0", "blurhash": "^2.0.5",