From 637b16abda174a77a381fa4515673e7e30a42234 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Wed, 12 Aug 2020 20:24:43 +0200 Subject: [PATCH] Add PermissionModule and GroupsModule Both currently contain only the database entities, taken from the schema. Signed-off-by: David Mehren --- src/app.module.ts | 4 ++++ src/groups/group.entity.ts | 23 +++++++++++++++++++ src/groups/groups.module.ts | 4 ++++ .../note-group-permission.entity.ts | 14 +++++++++++ .../note-user-permission.entity.ts | 14 +++++++++++ src/permissions/permissions.module.ts | 4 ++++ 6 files changed, 63 insertions(+) create mode 100644 src/groups/group.entity.ts create mode 100644 src/groups/groups.module.ts create mode 100644 src/permissions/note-group-permission.entity.ts create mode 100644 src/permissions/note-user-permission.entity.ts create mode 100644 src/permissions/permissions.module.ts diff --git a/src/app.module.ts b/src/app.module.ts index 60821e71a..dfaa4a445 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -7,6 +7,8 @@ import { RevisionsModule } from './revisions/revisions.module'; import { AuthorsModule } from './authors/authors.module'; import { HistoryModule } from './history/history.module'; import { MonitoringModule } from './monitoring/monitoring.module'; +import { PermissionsModule } from './permissions/permissions.module'; +import { GroupsModule } from './groups/groups.module'; @Module({ imports: [ @@ -23,6 +25,8 @@ import { MonitoringModule } from './monitoring/monitoring.module'; PublicApiModule, HistoryModule, MonitoringModule, + PermissionsModule, + GroupsModule, ], controllers: [], providers: [], diff --git a/src/groups/group.entity.ts b/src/groups/group.entity.ts new file mode 100644 index 000000000..28ce5bb2e --- /dev/null +++ b/src/groups/group.entity.ts @@ -0,0 +1,23 @@ +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm/index'; + +@Entity() +export class Group { + @PrimaryGeneratedColumn() + id: number; + + @Column({ + unique: true, + }) + name: string; + + @Column() + displayName: string; + + /** + * Is set to denote a special group + * Special groups are used to map the old share settings like "everyone can edit" + * or "logged in users can view" to the group permission system + */ + @Column() + special: boolean; +} diff --git a/src/groups/groups.module.ts b/src/groups/groups.module.ts new file mode 100644 index 000000000..1c5dea059 --- /dev/null +++ b/src/groups/groups.module.ts @@ -0,0 +1,4 @@ +import { Module } from '@nestjs/common'; + +@Module({}) +export class GroupsModule {} diff --git a/src/permissions/note-group-permission.entity.ts b/src/permissions/note-group-permission.entity.ts new file mode 100644 index 000000000..9c6be674f --- /dev/null +++ b/src/permissions/note-group-permission.entity.ts @@ -0,0 +1,14 @@ +import { Column, ManyToOne } from 'typeorm/index'; +import { Group } from '../groups/group.entity'; +import { Note } from '../notes/note.entity'; + +export class NoteGroupPermission { + @ManyToOne(_ => Group) + group: Group; + + @ManyToOne(_ => Note) + note: Note; + + @Column() + canEdit: boolean; +} diff --git a/src/permissions/note-user-permission.entity.ts b/src/permissions/note-user-permission.entity.ts new file mode 100644 index 000000000..7f86c57f6 --- /dev/null +++ b/src/permissions/note-user-permission.entity.ts @@ -0,0 +1,14 @@ +import { Column, ManyToOne } from 'typeorm/index'; +import { Note } from '../notes/note.entity'; +import { User } from '../users/user.entity'; + +export class NoteUserPermission { + @ManyToOne(_ => User) + user: User; + + @ManyToOne(_ => Note) + note: Note; + + @Column() + canEdit: boolean; +} diff --git a/src/permissions/permissions.module.ts b/src/permissions/permissions.module.ts new file mode 100644 index 000000000..18b5dba2a --- /dev/null +++ b/src/permissions/permissions.module.ts @@ -0,0 +1,4 @@ +import { Module } from '@nestjs/common'; + +@Module({}) +export class PermissionsModule {}