2021-01-05 16:12:38 -05:00
|
|
|
/*
|
2021-01-06 15:36:07 -05:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2021-01-05 16:12:38 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2020-07-26 14:58:40 -04:00
|
|
|
import { IsArray, IsBoolean, IsString, ValidateNested } from 'class-validator';
|
2020-07-25 14:24:59 -04:00
|
|
|
import { UserInfoDto } from '../users/user-info.dto';
|
2021-02-20 05:41:15 -05:00
|
|
|
import { GroupInfoDto } from '../groups/group-info.dto';
|
2020-07-25 14:24:59 -04:00
|
|
|
|
2020-07-26 16:34:04 -04:00
|
|
|
export class NoteUserPermissionEntryDto {
|
2021-01-25 16:22:52 -05:00
|
|
|
/**
|
|
|
|
* User this permission applies to
|
|
|
|
*/
|
2020-07-25 14:24:59 -04:00
|
|
|
@ValidateNested()
|
|
|
|
user: UserInfoDto;
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the user is allowed to edit the note
|
|
|
|
* @example false
|
|
|
|
*/
|
2020-07-25 14:24:59 -04:00
|
|
|
@IsBoolean()
|
|
|
|
canEdit: boolean;
|
|
|
|
}
|
|
|
|
|
2020-10-03 06:42:14 -04:00
|
|
|
export class NoteUserPermissionUpdateDto {
|
2021-01-25 16:22:52 -05:00
|
|
|
/**
|
|
|
|
* Username of the user this permission should apply to
|
|
|
|
* @example "john.smith"
|
|
|
|
*/
|
2020-07-26 14:58:40 -04:00
|
|
|
@IsString()
|
|
|
|
username: string;
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the user should be allowed to edit the note
|
|
|
|
* @example false
|
|
|
|
*/
|
2020-07-26 14:58:40 -04:00
|
|
|
@IsBoolean()
|
|
|
|
canEdit: boolean;
|
|
|
|
}
|
|
|
|
|
2020-07-26 16:34:04 -04:00
|
|
|
export class NoteGroupPermissionEntryDto {
|
2021-01-25 16:22:52 -05:00
|
|
|
/**
|
|
|
|
* Group this permission applies to
|
|
|
|
*/
|
2020-07-26 16:34:04 -04:00
|
|
|
@ValidateNested()
|
2020-07-27 16:38:46 -04:00
|
|
|
group: GroupInfoDto;
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the group members are allowed to edit the note
|
|
|
|
* @example false
|
|
|
|
*/
|
2020-07-26 16:34:04 -04:00
|
|
|
@IsBoolean()
|
2020-07-27 16:38:46 -04:00
|
|
|
canEdit: boolean;
|
2020-07-26 16:34:04 -04:00
|
|
|
}
|
|
|
|
|
2020-10-03 06:42:14 -04:00
|
|
|
export class NoteGroupPermissionUpdateDto {
|
2021-01-25 16:22:52 -05:00
|
|
|
/**
|
|
|
|
* Name of the group this permission should apply to
|
|
|
|
* @example "superheroes"
|
|
|
|
*/
|
2020-10-03 06:42:14 -04:00
|
|
|
@IsString()
|
|
|
|
groupname: string;
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the group members should be allowed to edit the note
|
|
|
|
* @example false
|
|
|
|
*/
|
2020-10-03 06:42:14 -04:00
|
|
|
@IsBoolean()
|
|
|
|
canEdit: boolean;
|
|
|
|
}
|
|
|
|
|
2020-07-25 14:24:59 -04:00
|
|
|
export class NotePermissionsDto {
|
2021-01-25 16:22:52 -05:00
|
|
|
/**
|
|
|
|
* User this permission applies to
|
|
|
|
*/
|
2020-07-25 14:24:59 -04:00
|
|
|
@ValidateNested()
|
|
|
|
owner: UserInfoDto;
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of users the note is shared with
|
|
|
|
*/
|
2020-07-25 14:24:59 -04:00
|
|
|
@ValidateNested()
|
|
|
|
@IsArray()
|
2020-07-26 16:34:04 -04:00
|
|
|
sharedToUsers: NoteUserPermissionEntryDto[];
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of groups the note is shared with
|
|
|
|
*/
|
2020-07-26 16:34:04 -04:00
|
|
|
@ValidateNested()
|
|
|
|
@IsArray()
|
|
|
|
sharedToGroups: NoteGroupPermissionEntryDto[];
|
2020-07-25 14:24:59 -04:00
|
|
|
}
|
2020-07-26 14:58:40 -04:00
|
|
|
|
|
|
|
export class NotePermissionsUpdateDto {
|
2021-01-25 16:22:52 -05:00
|
|
|
/**
|
|
|
|
* List of users the note should be shared with
|
|
|
|
*/
|
2020-07-26 14:58:40 -04:00
|
|
|
@IsArray()
|
|
|
|
@ValidateNested()
|
2020-10-03 06:42:14 -04:00
|
|
|
sharedToUsers: NoteUserPermissionUpdateDto[];
|
2021-01-25 16:22:52 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of groups the note should be shared with
|
|
|
|
*/
|
2020-10-03 06:42:14 -04:00
|
|
|
@IsArray()
|
|
|
|
@ValidateNested()
|
|
|
|
sharedToGroups: NoteGroupPermissionUpdateDto[];
|
2020-07-26 14:58:40 -04:00
|
|
|
}
|