mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor(federation): Make references always have domains
Some checks failed
CodeQL Scan / Analyze (push) Failing after 0s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / lint (push) Has been cancelled
Build Docker Images / check (push) Has been cancelled
Build Docker Images / tests (push) Has been cancelled
Build Docker Images / detect-circular (push) Has been cancelled
Mirror to Codeberg / Mirror (push) Has been cancelled
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been cancelled
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been cancelled
Some checks failed
CodeQL Scan / Analyze (push) Failing after 0s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / lint (push) Has been cancelled
Build Docker Images / check (push) Has been cancelled
Build Docker Images / tests (push) Has been cancelled
Build Docker Images / detect-circular (push) Has been cancelled
Mirror to Codeberg / Mirror (push) Has been cancelled
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been cancelled
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been cancelled
This commit is contained in:
parent
df2a5ce260
commit
709e1c6087
22 changed files with 688 additions and 477 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import * as VersiaEntities from "@versia/sdk/entities";
|
||||
import { config } from "@versia-server/config";
|
||||
import {
|
||||
and,
|
||||
desc,
|
||||
|
|
@ -20,7 +21,9 @@ import { BaseInterface } from "./base.ts";
|
|||
import type { User } from "./user.ts";
|
||||
|
||||
type LikeType = InferSelectModel<typeof Likes> & {
|
||||
liker: InferSelectModel<typeof Users>;
|
||||
liker: InferSelectModel<typeof Users> & {
|
||||
instance: InferSelectModel<typeof Instances> | null;
|
||||
};
|
||||
liked: InferSelectModel<typeof Notes> & {
|
||||
author: InferSelectModel<typeof Users> & {
|
||||
instance: InferSelectModel<typeof Instances> | null;
|
||||
|
|
@ -70,7 +73,11 @@ export class Like extends BaseInterface<typeof Likes, LikeType> {
|
|||
},
|
||||
},
|
||||
},
|
||||
liker: true,
|
||||
liker: {
|
||||
with: {
|
||||
instance: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -102,7 +109,11 @@ export class Like extends BaseInterface<typeof Likes, LikeType> {
|
|||
},
|
||||
},
|
||||
},
|
||||
liker: true,
|
||||
liker: {
|
||||
with: {
|
||||
instance: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -167,22 +178,28 @@ export class Like extends BaseInterface<typeof Likes, LikeType> {
|
|||
likedReference = `${this.data.liked.author.instance.domain}:${this.data.liked.remoteId}`;
|
||||
}
|
||||
|
||||
return new VersiaEntities.Like({
|
||||
id: this.id,
|
||||
author: this.data.liker.id,
|
||||
type: "pub.versia:likes/Like",
|
||||
created_at: this.data.createdAt.toISOString(),
|
||||
liked: likedReference,
|
||||
});
|
||||
return new VersiaEntities.Like(
|
||||
{
|
||||
id: this.id,
|
||||
author: this.data.liker.id,
|
||||
type: "pub.versia:likes/Like",
|
||||
created_at: this.data.createdAt.toISOString(),
|
||||
liked: likedReference,
|
||||
},
|
||||
this.data.liker.instance?.domain ?? config.http.base_url.hostname,
|
||||
);
|
||||
}
|
||||
|
||||
public unlikeToVersia(unliker?: User): VersiaEntities.Delete {
|
||||
return new VersiaEntities.Delete({
|
||||
type: "Delete",
|
||||
created_at: new Date().toISOString(),
|
||||
author: unliker ? unliker.id : this.data.liker.id,
|
||||
deleted_type: "pub.versia:likes/Like",
|
||||
deleted: this.id,
|
||||
});
|
||||
return new VersiaEntities.Delete(
|
||||
{
|
||||
type: "Delete",
|
||||
created_at: new Date().toISOString(),
|
||||
author: unliker ? unliker.id : this.data.liker.id,
|
||||
deleted_type: "pub.versia:likes/Like",
|
||||
deleted: this.id,
|
||||
},
|
||||
this.data.liker.instance?.domain ?? config.http.base_url.hostname,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue