mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
More refactoring, API route fixes
This commit is contained in:
parent
3b452d66aa
commit
95b46ba2e4
6 changed files with 72 additions and 16 deletions
|
|
@ -7,7 +7,6 @@ import {
|
|||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
RemoveOptions,
|
||||
UpdateDateColumn,
|
||||
|
|
@ -46,7 +45,10 @@ export class Status extends BaseEntity {
|
|||
})
|
||||
reblog?: Status;
|
||||
|
||||
@OneToOne(() => Status)
|
||||
@ManyToOne(() => RawObject, {
|
||||
nullable: true,
|
||||
onDelete: "SET NULL",
|
||||
})
|
||||
object!: RawObject;
|
||||
|
||||
@Column("boolean")
|
||||
|
|
@ -63,12 +65,12 @@ export class Status extends BaseEntity {
|
|||
@ManyToOne(() => RawObject, {
|
||||
nullable: true,
|
||||
})
|
||||
in_reply_to_post!: RawObject;
|
||||
in_reply_to_post!: RawObject | null;
|
||||
|
||||
@ManyToOne(() => RawActor, {
|
||||
nullable: true,
|
||||
})
|
||||
in_reply_to_account!: RawActor;
|
||||
in_reply_to_account!: RawActor | null;
|
||||
|
||||
@Column("boolean")
|
||||
sensitive!: boolean;
|
||||
|
|
@ -99,9 +101,7 @@ export class Status extends BaseEntity {
|
|||
// Delete object
|
||||
await this.object.remove(options);
|
||||
|
||||
await super.remove(options);
|
||||
|
||||
return this;
|
||||
return await super.remove(options);
|
||||
}
|
||||
|
||||
static async createNew(data: {
|
||||
|
|
@ -225,7 +225,7 @@ export class Status extends BaseEntity {
|
|||
}
|
||||
|
||||
// TODO: Add default language
|
||||
|
||||
await newStatus.object.save();
|
||||
await newStatus.save();
|
||||
return newStatus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {
|
|||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
RemoveOptions,
|
||||
UpdateDateColumn,
|
||||
} from "typeorm";
|
||||
import { APIAccount } from "~types/entities/account";
|
||||
|
|
@ -174,7 +175,7 @@ export class User extends BaseEntity {
|
|||
return relationship;
|
||||
}
|
||||
|
||||
async selfDestruct() {
|
||||
async remove(options?: RemoveOptions | undefined) {
|
||||
// Clean up tokens
|
||||
const tokens = await Token.findBy({
|
||||
user: {
|
||||
|
|
@ -182,9 +183,14 @@ export class User extends BaseEntity {
|
|||
},
|
||||
});
|
||||
|
||||
const statuses = await Status.findBy({
|
||||
account: {
|
||||
id: this.id,
|
||||
const statuses = await Status.find({
|
||||
where: {
|
||||
account: {
|
||||
id: this.id,
|
||||
},
|
||||
},
|
||||
relations: {
|
||||
object: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -199,6 +205,8 @@ export class User extends BaseEntity {
|
|||
await Promise.all(
|
||||
relationships.map(async relationship => await relationship.remove())
|
||||
);
|
||||
|
||||
return await super.remove(options);
|
||||
}
|
||||
|
||||
async getRelationships() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue