parent
04fefb2056
commit
576251200f
17 changed files with 18 additions and 324 deletions
|
|
@ -53,14 +53,6 @@ export const meta = {
|
|||
type: 'boolean',
|
||||
optional: true, nullable: false,
|
||||
},
|
||||
isPrivate: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: true,
|
||||
},
|
||||
closeDuration: {
|
||||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -73,7 +65,6 @@ export const paramDef = {
|
|||
withUnreads: { type: 'boolean', default: false },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
privateOnly: { type: 'boolean', default: false },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
|
@ -91,19 +82,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const builder = this.announcementsRepository.createQueryBuilder('announcement');
|
||||
if (me) {
|
||||
if (ps.privateOnly) {
|
||||
builder.where('"userId" = :userId', { userId: me.id });
|
||||
} else {
|
||||
builder.where('"userId" IS NULL');
|
||||
builder.orWhere('"userId" = :userId', { userId: me.id });
|
||||
}
|
||||
} else {
|
||||
builder.where('"userId" IS NULL');
|
||||
}
|
||||
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
||||
|
||||
const query = this.queryService.makePaginationQuery(builder, ps.sinceId, ps.untilId);
|
||||
const announcements = await query.limit(ps.limit).getMany();
|
||||
|
||||
if (me) {
|
||||
|
|
@ -120,7 +100,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
...a,
|
||||
createdAt: a.createdAt.toISOString(),
|
||||
updatedAt: a.updatedAt?.toISOString() ?? null,
|
||||
isPrivate: !!a.userId,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue