mirror of
https://github.com/versia-pub/server.git
synced 2025-12-08 17:28: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 {
|
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) {
|
if (!id) {
|
||||||
return null;
|
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) =>
|
mentions: status.mentions.map((mention) =>
|
||||||
User.getUri(mention.id, mention.uri, config.http.base_url),
|
User.getUri(mention.id, mention.uri, config.http.base_url),
|
||||||
),
|
),
|
||||||
quotes: Note.getUri(status.quotingId) ?? undefined,
|
quotes:
|
||||||
replies_to: Note.getUri(status.replyId) ?? undefined,
|
Note.getUri(status.quotingId, status.quote?.uri) ?? undefined,
|
||||||
|
replies_to:
|
||||||
|
Note.getUri(status.replyId, status.quote?.uri) ?? undefined,
|
||||||
subject: status.spoilerText,
|
subject: status.spoilerText,
|
||||||
visibility: status.visibility as
|
visibility: status.visibility as
|
||||||
| "public"
|
| "public"
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,11 @@ export default (app: Hono) =>
|
||||||
apiObject = foundObject ? foundObject.toLysand() : null;
|
apiObject = foundObject ? foundObject.toLysand() : null;
|
||||||
foundAuthor = foundObject ? foundObject.author : null;
|
foundAuthor = foundObject ? foundObject.author : null;
|
||||||
|
|
||||||
if (!foundObject) {
|
if (foundObject) {
|
||||||
|
if (!foundObject.isViewableByUser(null)) {
|
||||||
|
return errorResponse("Object not found", 404);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
foundObject =
|
foundObject =
|
||||||
(await db.query.Likes.findFirst({
|
(await db.query.Likes.findFirst({
|
||||||
where: (like, { eq, and }) =>
|
where: (like, { eq, and }) =>
|
||||||
|
|
@ -78,6 +82,13 @@ export default (app: Hono) =>
|
||||||
return errorResponse("Object not found", 404);
|
return errorResponse("Object not found", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foundAuthor?.isRemote()) {
|
||||||
|
return errorResponse(
|
||||||
|
"Cannot view objects from remote instances",
|
||||||
|
403,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
return response(JSON.stringify(apiObject, null, 4), 200, {
|
return response(JSON.stringify(apiObject, null, 4), 200, {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue