2023-07-27 05:31:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-02-16 14:09:41 +00:00
|
|
|
import { Entity, Column, PrimaryColumn } from 'typeorm';
|
2023-09-20 02:33:36 +00:00
|
|
|
import { id } from './util/id.js';
|
2023-01-12 12:02:26 +00:00
|
|
|
|
2023-01-13 02:03:54 +00:00
|
|
|
type CondFormulaValueAnd = {
|
|
|
|
type: 'and';
|
|
|
|
values: RoleCondFormulaValue[];
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueOr = {
|
|
|
|
type: 'or';
|
|
|
|
values: RoleCondFormulaValue[];
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueNot = {
|
|
|
|
type: 'not';
|
|
|
|
value: RoleCondFormulaValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueIsLocal = {
|
|
|
|
type: 'isLocal';
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueIsRemote = {
|
|
|
|
type: 'isRemote';
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueCreatedLessThan = {
|
|
|
|
type: 'createdLessThan';
|
|
|
|
sec: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueCreatedMoreThan = {
|
|
|
|
type: 'createdMoreThan';
|
|
|
|
sec: number;
|
|
|
|
};
|
|
|
|
|
2023-01-13 23:27:23 +00:00
|
|
|
type CondFormulaValueFollowersLessThanOrEq = {
|
|
|
|
type: 'followersLessThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueFollowersMoreThanOrEq = {
|
|
|
|
type: 'followersMoreThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueFollowingLessThanOrEq = {
|
|
|
|
type: 'followingLessThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueFollowingMoreThanOrEq = {
|
|
|
|
type: 'followingMoreThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
2023-03-23 08:18:38 +00:00
|
|
|
type CondFormulaValueNotesLessThanOrEq = {
|
|
|
|
type: 'notesLessThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueNotesMoreThanOrEq = {
|
|
|
|
type: 'notesMoreThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
2023-01-13 02:03:54 +00:00
|
|
|
export type RoleCondFormulaValue =
|
|
|
|
CondFormulaValueAnd |
|
|
|
|
CondFormulaValueOr |
|
|
|
|
CondFormulaValueNot |
|
|
|
|
CondFormulaValueIsLocal |
|
|
|
|
CondFormulaValueIsRemote |
|
|
|
|
CondFormulaValueCreatedLessThan |
|
2023-01-13 23:27:23 +00:00
|
|
|
CondFormulaValueCreatedMoreThan |
|
|
|
|
CondFormulaValueFollowersLessThanOrEq |
|
|
|
|
CondFormulaValueFollowersMoreThanOrEq |
|
|
|
|
CondFormulaValueFollowingLessThanOrEq |
|
2023-03-23 08:18:38 +00:00
|
|
|
CondFormulaValueFollowingMoreThanOrEq |
|
|
|
|
CondFormulaValueNotesLessThanOrEq |
|
|
|
|
CondFormulaValueNotesMoreThanOrEq;
|
2023-01-13 02:03:54 +00:00
|
|
|
|
2023-08-16 08:51:28 +00:00
|
|
|
@Entity('role')
|
|
|
|
export class MiRole {
|
2023-01-12 12:02:26 +00:00
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The updated date of the Role.',
|
|
|
|
})
|
|
|
|
public updatedAt: Date;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The last used date of the Role.',
|
|
|
|
})
|
|
|
|
public lastUsedAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 1024,
|
|
|
|
})
|
|
|
|
public description: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256, nullable: true,
|
|
|
|
})
|
|
|
|
public color: string | null;
|
|
|
|
|
2023-02-05 01:37:03 +00:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
|
|
|
})
|
|
|
|
public iconUrl: string | null;
|
|
|
|
|
2023-01-13 02:03:54 +00:00
|
|
|
@Column('enum', {
|
|
|
|
enum: ['manual', 'conditional'],
|
|
|
|
default: 'manual',
|
|
|
|
})
|
|
|
|
public target: 'manual' | 'conditional';
|
|
|
|
|
|
|
|
@Column('jsonb', {
|
|
|
|
default: { },
|
|
|
|
})
|
|
|
|
public condFormula: RoleCondFormulaValue;
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isPublic: boolean;
|
|
|
|
|
2023-02-05 01:37:03 +00:00
|
|
|
// trueの場合ユーザー名の横にバッジとして表示
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public asBadge: boolean;
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isModerator: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isAdministrator: boolean;
|
|
|
|
|
2023-04-20 11:02:50 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isExplorable: boolean;
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public canEditMembersByModerator: boolean;
|
|
|
|
|
2023-03-12 07:38:08 +00:00
|
|
|
// UIに表示する際の並び順用(大きいほど先頭)
|
|
|
|
@Column('integer', {
|
|
|
|
default: 0,
|
|
|
|
})
|
|
|
|
public displayOrder: number;
|
|
|
|
|
2023-01-12 12:02:26 +00:00
|
|
|
@Column('jsonb', {
|
|
|
|
default: { },
|
|
|
|
})
|
2023-01-15 11:52:53 +00:00
|
|
|
public policies: Record<string, {
|
2023-01-12 12:02:26 +00:00
|
|
|
useDefault: boolean;
|
2023-01-15 10:10:39 +00:00
|
|
|
priority: number;
|
2023-01-12 12:02:26 +00:00
|
|
|
value: any;
|
|
|
|
}>;
|
|
|
|
}
|