mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 09:04:44 -04:00
NotePermissions: Remove default constructors
As discussed in #835 we don't want to have default constructors and prefer .create methods. Because the created NoteGroupPermission and NoteUserPermission are not saved to the DB by themselves, but are saved via a change to the Note using a Pick<Class, attributes>-style return type is not helpful here as every single time the .create functions are called a full object is required. The mock calls in the PermissionService test are not needed and break the .create calls so they got removed. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
195aeed5eb
commit
292944ed78
3 changed files with 21 additions and 9 deletions
|
@ -18,4 +18,14 @@ export class NoteGroupPermission {
|
|||
|
||||
@Column()
|
||||
canEdit: boolean;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
private constructor() {}
|
||||
|
||||
public static create(group: Group, canEdit: boolean): NoteGroupPermission {
|
||||
const groupPermission = new NoteGroupPermission();
|
||||
groupPermission.group = group;
|
||||
groupPermission.canEdit = canEdit;
|
||||
return groupPermission;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue