fix: bố cục lại cách hiển thị thông tin ảnh
This commit is contained in:
Vendored
+45
@@ -1732,6 +1732,42 @@ let PhotoController = class PhotoController {
|
||||
}
|
||||
});
|
||||
}
|
||||
async toggleLikePhoto(id, req) {
|
||||
const userId = req.user.id;
|
||||
const photo = await this.prisma.photo.findUnique({
|
||||
where: { id }
|
||||
});
|
||||
if (!photo) {
|
||||
throw new common_1.NotFoundException('Không tìm thấy ảnh.');
|
||||
}
|
||||
const currentMetadata = photo.metadata || {};
|
||||
const likedUserIds = Array.isArray(currentMetadata.likedUserIds)
|
||||
? currentMetadata.likedUserIds
|
||||
: [];
|
||||
const index = likedUserIds.indexOf(userId);
|
||||
let updatedLikedUserIds = [...likedUserIds];
|
||||
if (index > -1) {
|
||||
updatedLikedUserIds.splice(index, 1);
|
||||
}
|
||||
else {
|
||||
updatedLikedUserIds.push(userId);
|
||||
}
|
||||
const updatedMetadata = {
|
||||
...currentMetadata,
|
||||
likedUserIds: updatedLikedUserIds
|
||||
};
|
||||
return this.prisma.photo.update({
|
||||
where: { id },
|
||||
data: {
|
||||
metadata: updatedMetadata
|
||||
},
|
||||
include: {
|
||||
uploader: {
|
||||
select: { id: true, name: true }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Post)('upload-anonymous'),
|
||||
@@ -1760,6 +1796,15 @@ __decorate([
|
||||
__metadata("design:paramtypes", [String, Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], PhotoController.prototype, "updatePhoto", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)(':id/toggle-like'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], PhotoController.prototype, "toggleLikePhoto", null);
|
||||
PhotoController = __decorate([
|
||||
(0, common_1.Controller)('photos'),
|
||||
(0, exports.Roles)(client_1.ParticipantRole.OWNER, client_1.ParticipantRole.MANAGER, client_1.ParticipantRole.MEMBER, client_1.ParticipantRole.MEMBER_NO_FINANCE),
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user