Add for leave family
This commit is contained in:
@@ -5,7 +5,7 @@ import { firstValueFrom } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { getAuthorizedUserId } from '../document-access';
|
||||
import { AddFamilyMemberDto, CreateFamilyGroupDto, RespondFamilyInviteDto, SendFamilyInviteDto, UpdateFamilyGroupDto } from '../dto/identity.dto';
|
||||
import { AddFamilyMemberDto, CreateFamilyGroupDto, LeaveFamilyGroupDto, RespondFamilyInviteDto, SendFamilyInviteDto, UpdateFamilyGroupDto } from '../dto/identity.dto';
|
||||
|
||||
@ApiTags('Семья')
|
||||
@ApiBearerAuth()
|
||||
@@ -91,6 +91,23 @@ export class FamilyController {
|
||||
return firstValueFrom(this.core.family.RemoveFamilyMember({ requesterId, memberId }));
|
||||
}
|
||||
|
||||
@Post('groups/:groupId/leave')
|
||||
@ApiOperation({ summary: 'Покинуть семейную группу' })
|
||||
async leaveGroup(
|
||||
@Headers('authorization') authorization: string | undefined,
|
||||
@Param('groupId') groupId: string,
|
||||
@Body() dto: LeaveFamilyGroupDto
|
||||
) {
|
||||
const requesterId = await this.auth(authorization);
|
||||
return firstValueFrom(
|
||||
this.core.family.LeaveFamilyGroup({
|
||||
requesterId,
|
||||
groupId,
|
||||
newOwnerUserId: dto.newOwnerUserId
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Get('groups/:groupId/invite-search')
|
||||
@ApiOperation({ summary: 'Поиск пользователей для приглашения в семью' })
|
||||
async searchInviteUsers(
|
||||
|
||||
@@ -154,3 +154,10 @@ export class RespondFamilyInviteDto {
|
||||
accept!: boolean;
|
||||
}
|
||||
|
||||
export class LeaveFamilyGroupDto {
|
||||
@ApiPropertyOptional({ description: 'ID нового главы семьи (обязателен для создателя при наличии других участников)' })
|
||||
@IsOptional()
|
||||
@IsString({ message: 'ID нового главы семьи должен быть строкой' })
|
||||
newOwnerUserId?: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user