🐛 Fix deleted message event notifying issue
This commit is contained in:
parent
8bf45bdefe
commit
f50e376f6c
@ -34,7 +34,7 @@ func getEvent(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusForbidden, fmt.Sprintf("you need join the channel before you read the messages: %v", err))
|
return fiber.NewError(fiber.StatusForbidden, fmt.Sprintf("you need join the channel before you read the messages: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
event, err := services.GetEvent(channel, uint(id))
|
event, err := services.GetEvent(channel.ID, uint(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,10 @@ func ListEvent(channel models.Channel, take int, offset int) ([]models.Event, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEvent(channel models.Channel, id uint) (models.Event, error) {
|
func GetEvent(channelId uint, id uint) (models.Event, error) {
|
||||||
var event models.Event
|
var event models.Event
|
||||||
if err := database.C.
|
if err := database.C.
|
||||||
Where("id = ? AND channel_id = ?", id, channel.ID).
|
Where("id = ? AND channel_id = ?", id, channelId).
|
||||||
Preload("Sender").
|
Preload("Sender").
|
||||||
First(&event).Error; err != nil {
|
First(&event).Error; err != nil {
|
||||||
return event, err
|
return event, err
|
||||||
@ -83,7 +83,7 @@ func NewEvent(event models.Event) (models.Event, error) {
|
|||||||
return event, nil
|
return event, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
event, err := GetEvent(event.Channel, event.ID)
|
event, err := GetEvent(event.ChannelID, event.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to fetch event, the notifying of new event was terminated...")
|
log.Error().Err(err).Msg("Failed to fetch event, the notifying of new event was terminated...")
|
||||||
return event, err
|
return event, err
|
||||||
|
Loading…
Reference in New Issue
Block a user