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
|
|
|
|
*/
|
2021-08-29 12:45:46 -04:00
|
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
2021-04-29 12:29:12 -04:00
|
|
|
import {
|
|
|
|
IsArray,
|
|
|
|
IsBoolean,
|
|
|
|
IsOptional,
|
|
|
|
IsString,
|
|
|
|
ValidateNested,
|
|
|
|
} from 'class-validator';
|
2021-08-29 12:45:46 -04:00
|
|
|
|
2021-02-20 05:41:15 -05:00
|
|
|
import { GroupInfoDto } from '../groups/group-info.dto';
|
2021-08-29 12:45:46 -04:00
|
|
|
import { UserInfoDto } from '../users/user-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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty({ type: UserInfoDto })
|
2020-07-25 14:24:59 -04:00
|
|
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty()
|
2020-07-25 14:24:59 -04:00
|
|
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty()
|
2020-07-26 14:58:40 -04:00
|
|
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty()
|
2020-07-26 14:58:40 -04:00
|
|
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty({ type: GroupInfoDto })
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty()
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty()
|
2020-10-03 06:42:14 -04:00
|
|
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty()
|
2020-10-03 06:42:14 -04:00
|
|
|
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()
|
2021-04-29 12:29:12 -04:00
|
|
|
@ApiPropertyOptional({ type: UserInfoDto })
|
|
|
|
@IsOptional()
|
2021-05-02 12:33:07 -04:00
|
|
|
owner: UserInfoDto | null;
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty({ isArray: true, type: NoteUserPermissionEntryDto })
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty({ isArray: true, type: NoteGroupPermissionEntryDto })
|
2020-07-26 16:34:04 -04:00
|
|
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty({ isArray: true, type: NoteUserPermissionUpdateDto })
|
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()
|
2021-03-19 07:08:34 -04:00
|
|
|
@ApiProperty({ isArray: true, type: NoteGroupPermissionUpdateDto })
|
2020-10-03 06:42:14 -04:00
|
|
|
sharedToGroups: NoteGroupPermissionUpdateDto[];
|
2020-07-26 14:58:40 -04:00
|
|
|
}
|