3
0

Inc/dec reply counter on original message before sending payload back to clients

This commit is contained in:
Denis Arh 2018-10-23 12:58:57 +02:00
parent 98fb60cf59
commit 8347a645cb

View File

@ -145,7 +145,8 @@ func (svc *message) Create(mod *types.Message) (message *types.Message, err erro
mod.ChannelID = original.ChannelID
//
// Increment counter, on struct and in repostiry.
original.Replies++
if err = svc.message.IncReplyCount(original.ID); err != nil {
return
}
@ -227,7 +228,12 @@ func (svc *message) Delete(ID uint64) error {
return err
}
// This is a reply to another message, decrease reply counter on the original
// This is a reply to another message, decrease reply counter on the original, on struct and in the
// repository
if original.Replies > 0 {
original.Replies--
}
if err = svc.message.DecReplyCount(original.ID); err != nil {
return err
}