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:
Philip Molares 2021-02-20 11:38:50 +01:00
parent 353384435e
commit 577811be29
3 changed files with 21 additions and 9 deletions

View file

@ -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;
}
}