mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
fix(federation): 🐛 Fix issues with note federation URIs
This commit is contained in:
parent
92a80d97c2
commit
903415161e
|
|
@ -864,14 +864,14 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
|
|||
}
|
||||
|
||||
getUri(): string {
|
||||
return localObjectUri(this.data.id);
|
||||
return this.data.uri || localObjectUri(this.id);
|
||||
}
|
||||
|
||||
static getUri(id?: string | null): string | null {
|
||||
static getUri(id: string | null, uri?: string | null): string | null {
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
return localObjectUri(id);
|
||||
return uri || localObjectUri(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -912,8 +912,10 @@ export class Note extends BaseInterface<typeof Notes, StatusWithRelations> {
|
|||
mentions: status.mentions.map((mention) =>
|
||||
User.getUri(mention.id, mention.uri, config.http.base_url),
|
||||
),
|
||||
quotes: Note.getUri(status.quotingId) ?? undefined,
|
||||
replies_to: Note.getUri(status.replyId) ?? undefined,
|
||||
quotes:
|
||||
Note.getUri(status.quotingId, status.quote?.uri) ?? undefined,
|
||||
replies_to:
|
||||
Note.getUri(status.replyId, status.quote?.uri) ?? undefined,
|
||||
subject: status.spoilerText,
|
||||
visibility: status.visibility as
|
||||
| "public"
|
||||
|
|
|
|||
|
|
@ -59,7 +59,11 @@ export default (app: Hono) =>
|
|||
apiObject = foundObject ? foundObject.toLysand() : null;
|
||||
foundAuthor = foundObject ? foundObject.author : null;
|
||||
|
||||
if (!foundObject) {
|
||||
if (foundObject) {
|
||||
if (!foundObject.isViewableByUser(null)) {
|
||||
return errorResponse("Object not found", 404);
|
||||
}
|
||||
} else {
|
||||
foundObject =
|
||||
(await db.query.Likes.findFirst({
|
||||
where: (like, { eq, and }) =>
|
||||
|
|
@ -78,6 +82,13 @@ export default (app: Hono) =>
|
|||
return errorResponse("Object not found", 404);
|
||||
}
|
||||
|
||||
if (foundAuthor?.isRemote()) {
|
||||
return errorResponse(
|
||||
"Cannot view objects from remote instances",
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
return response(JSON.stringify(apiObject, null, 4), 200, {
|
||||
"Content-Type": "application/json",
|
||||
|
|
|
|||
Loading…
Reference in a new issue