forRoles IS NOT NULL, coalesce to empty=unrestricted
This commit is contained in:
parent
f3b5c3f447
commit
b61c1d5b27
9 changed files with 16 additions and 16 deletions
|
|
@ -63,7 +63,7 @@ export class AnnouncementService {
|
|||
}))
|
||||
.andWhere(new Brackets(qb => {
|
||||
qb.orWhere('announcement.forRoles && :roles', { roles: roles.map((r) => r.id) });
|
||||
qb.orWhere('announcement.forRoles IS NULL');
|
||||
qb.orWhere('announcement.forRoles = \'{}\'');
|
||||
}))
|
||||
.andWhere(`announcement.id NOT IN (${ readsQuery.getQuery() })`);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,9 +69,9 @@ export class MiAnnouncement {
|
|||
|
||||
@Column('text', {
|
||||
array: true,
|
||||
default: null, nullable: true,
|
||||
default: '{}', nullable: false,
|
||||
})
|
||||
public forRoles: MiRole['id'][] | null;
|
||||
public forRoles: MiRole['id'][];
|
||||
|
||||
@Index()
|
||||
@Column('boolean', {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export const paramDef = {
|
|||
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'], default: 'info' },
|
||||
display: { type: 'string', enum: ['normal', 'banner', 'dialog'], default: 'normal' },
|
||||
forExistingUsers: { type: 'boolean', default: false },
|
||||
forRoles: { type: 'array', nullable: true, default: null, items: { type: 'string', nullable: false, format: 'misskey:id' }, },
|
||||
forRoles: { type: 'array', default: [], items: { type: 'string', nullable: false, format: 'misskey:id' }, },
|
||||
silence: { type: 'boolean', default: false },
|
||||
needConfirmationToRead: { type: 'boolean', default: false },
|
||||
confetti: { type: 'boolean', default: false },
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export const meta = {
|
|||
},
|
||||
forRoles: {
|
||||
type: 'array',
|
||||
optional: false, nullable: true,
|
||||
optional: false, nullable: false,
|
||||
items: {
|
||||
type: 'string',
|
||||
optional: false, nullable: false,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export const paramDef = {
|
|||
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'] },
|
||||
display: { type: 'string', enum: ['normal', 'banner', 'dialog'] },
|
||||
forExistingUsers: { type: 'boolean' },
|
||||
forRoles: { type: 'array', nullable: true, default: null, items: { type: 'string', nullable: false, format: 'misskey:id' }, },
|
||||
forRoles: { type: 'array', default: [], items: { type: 'string', nullable: false, format: 'misskey:id' }, },
|
||||
silence: { type: 'boolean' },
|
||||
needConfirmationToRead: { type: 'boolean' },
|
||||
confetti: { type: 'boolean' },
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}))
|
||||
.andWhere(new Brackets(qb => {
|
||||
if (me) qb.orWhere('announcement.forRoles && :roles', { roles: roles.map((r) => r.id) });
|
||||
qb.orWhere('announcement.forRoles IS NULL');
|
||||
qb.orWhere('announcement.forRoles = \'{}\'');
|
||||
}));
|
||||
|
||||
const announcements = await query.limit(ps.limit).getMany();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue