mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
Merge pull request #1039 from hedgedoc/fix/permissionsCreationAndFinding
This commit is contained in:
commit
eaa5254418
5 changed files with 54 additions and 5 deletions
|
@ -39,9 +39,14 @@ export class Note {
|
|||
@OneToMany(
|
||||
(_) => NoteGroupPermission,
|
||||
(groupPermission) => groupPermission.note,
|
||||
{ cascade: true }, // This ensures that embedded NoteGroupPermissions are automatically saved to the database
|
||||
)
|
||||
groupPermissions: NoteGroupPermission[];
|
||||
@OneToMany((_) => NoteUserPermission, (userPermission) => userPermission.note)
|
||||
@OneToMany(
|
||||
(_) => NoteUserPermission,
|
||||
(userPermission) => userPermission.note,
|
||||
{ cascade: true }, // This ensures that embedded NoteUserPermission are automatically saved to the database
|
||||
)
|
||||
userPermissions: NoteUserPermission[];
|
||||
@Column({
|
||||
nullable: false,
|
||||
|
|
|
@ -183,7 +183,9 @@ export class NotesService {
|
|||
'authorColors',
|
||||
'owner',
|
||||
'groupPermissions',
|
||||
'groupPermissions.group',
|
||||
'userPermissions',
|
||||
'userPermissions.user',
|
||||
'tags',
|
||||
],
|
||||
});
|
||||
|
@ -224,6 +226,8 @@ export class NotesService {
|
|||
//TODO: Calculate patch
|
||||
revisions.push(Revision.create(noteContent, noteContent));
|
||||
note.revisions = Promise.resolve(revisions);
|
||||
note.userPermissions = [];
|
||||
note.groupPermissions = [];
|
||||
return await this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
|
@ -270,6 +274,7 @@ export class NotesService {
|
|||
user,
|
||||
newUserPermission.canEdit,
|
||||
);
|
||||
createdPermission.note = note;
|
||||
note.userPermissions.push(createdPermission);
|
||||
}
|
||||
|
||||
|
@ -282,6 +287,7 @@ export class NotesService {
|
|||
group,
|
||||
newGroupPermission.canEdit,
|
||||
);
|
||||
createdPermission.note = note;
|
||||
note.groupPermissions.push(createdPermission);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue