fix: comment pin only once
This commit is contained in:
@@ -297,18 +297,24 @@ export class CommentController {
|
|||||||
!isUndefined(pin) && Reflect.set(updateResult, 'pin', pin)
|
!isUndefined(pin) && Reflect.set(updateResult, 'pin', pin)
|
||||||
|
|
||||||
if (pin) {
|
if (pin) {
|
||||||
await this.commentService.model
|
const currentRefModel = await this.commentService.model
|
||||||
.updateMany(
|
.findOne({
|
||||||
|
_id: id,
|
||||||
|
})
|
||||||
|
.lean()
|
||||||
|
.populate('ref')
|
||||||
|
|
||||||
|
const refId = (currentRefModel?.ref as any)?._id
|
||||||
|
if (refId) {
|
||||||
|
await this.commentService.model.updateMany(
|
||||||
{
|
{
|
||||||
_id: id,
|
ref: refId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
pin: false,
|
||||||
pin: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.exec()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user