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
353384435e
commit
577811be29
3 changed files with 21 additions and 9 deletions
|
@ -18,4 +18,14 @@ export class NoteUserPermission {
|
|||
|
||||
@Column()
|
||||
canEdit: boolean;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
private constructor() {}
|
||||
|
||||
public static create(user: User, canEdit: boolean): NoteUserPermission {
|
||||
const userPermission = new NoteUserPermission();
|
||||
userPermission.user = user;
|
||||
userPermission.canEdit = canEdit;
|
||||
return userPermission;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue