More API tests, fixes

This commit is contained in:
Jesse Wierzbinski 2023-10-22 15:47:04 -10:00
parent 932fc3e4f5
commit d05b077df1
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
10 changed files with 90 additions and 28 deletions

View file

@ -21,6 +21,21 @@ import { Instance } from "./Instance";
const config = getConfig();
export const statusRelations = [
"account",
"reblog",
"object",
"in_reply_to_post",
"instance",
"in_reply_to_account",
"in_reply_to_post.account",
"application",
"emojis",
"mentions",
"likes",
"announces",
];
/**
* Represents a status (i.e. a post)
*/
@ -57,8 +72,9 @@ export class Status extends BaseEntity {
*/
@ManyToOne(() => Status, status => status.id, {
nullable: true,
onDelete: "SET NULL",
})
reblog?: Status;
reblog?: Status | null;
/**
* The raw object associated with this status.
@ -94,6 +110,7 @@ export class Status extends BaseEntity {
*/
@ManyToOne(() => Status, {
nullable: true,
onDelete: "SET NULL",
})
in_reply_to_post!: Status | null;
@ -229,9 +246,7 @@ export class Status extends BaseEntity {
where: {
id: id,
},
relations: {
in_reply_to_post: true,
},
relations: statusRelations,
});
if (currentStatus) {
@ -279,9 +294,7 @@ export class Status extends BaseEntity {
id: status.id,
},
},
relations: {
in_reply_to_post: true,
},
relations: statusRelations,
});
for (const status of currentStatus) {
@ -443,6 +456,8 @@ export class Status extends BaseEntity {
return {
...(await this.object.toAPI()),
id: this.id,
in_reply_to_id: this.in_reply_to_post?.id || null,
in_reply_to_account_id: this.in_reply_to_post?.account.id || null,
};
}
}

View file

@ -21,7 +21,7 @@ import {
} from "activitypub-types";
import { RawObject } from "./RawObject";
import { Token } from "./Token";
import { Status } from "./Status";
import { Status, statusRelations } from "./Status";
import { APISource } from "~types/entities/source";
import { Relationship } from "./Relationship";
import { Instance } from "./Instance";
@ -368,9 +368,7 @@ export class User extends BaseEntity {
id: this.id,
},
},
relations: {
object: true,
},
relations: statusRelations,
});
// Delete both