🐛 Bug fixes of deletion
This commit is contained in:
parent
a85da44af1
commit
b49e57337a
@ -117,19 +117,20 @@ func EditMessage(message models.Message) (models.Message, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteMessage(message models.Message) (models.Message, error) {
|
func DeleteMessage(message models.Message) (models.Message, error) {
|
||||||
|
prev, _ := GetMessage(models.Channel{
|
||||||
|
BaseModel: models.BaseModel{ID: message.Channel.ID},
|
||||||
|
}, message.ID)
|
||||||
|
|
||||||
var members []models.ChannelMember
|
var members []models.ChannelMember
|
||||||
if err := database.C.Delete(&message).Error; err != nil {
|
if err := database.C.Delete(&message).Error; err != nil {
|
||||||
return message, err
|
return message, err
|
||||||
} else if err = database.C.Where(models.ChannelMember{
|
} else if err = database.C.Where(models.ChannelMember{
|
||||||
ChannelID: message.ChannelID,
|
ChannelID: message.ChannelID,
|
||||||
}).Find(&members).Error; err == nil {
|
}).Find(&members).Error; err == nil {
|
||||||
message, _ = GetMessage(models.Channel{
|
|
||||||
BaseModel: models.BaseModel{ID: message.Channel.ID},
|
|
||||||
}, message.ID)
|
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
PushCommand(member.AccountID, models.UnifiedCommand{
|
PushCommand(member.AccountID, models.UnifiedCommand{
|
||||||
Action: "messages.burnt",
|
Action: "messages.burnt",
|
||||||
Payload: message,
|
Payload: prev,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user