🐛 Remove related event foreign key to prevent issue when linking to a deleted event

This commit is contained in:
LittleSheep 2024-12-08 11:46:56 +08:00
parent 7a33018e44
commit a78fff8897
2 changed files with 2 additions and 3 deletions

View File

@ -21,9 +21,7 @@ type Event struct {
Channel Channel `json:"channel"`
Sender ChannelMember `json:"sender"`
QuoteEventID *uint `json:"quote_event_id,omitempty"`
QuoteEvent *Event `json:"quote_event,omitempty" gorm:"foreignKey:QuoteEventID"`
RelatedEventID *uint `json:"related_event_id,omitempty"`
RelatedEvent *Event `json:"related_event,omitempty" gorm:"foreignKey:RelatedEventID"`
ChannelID uint `json:"channel_id"`
SenderID uint `json:"sender_id"`
}

View File

@ -38,7 +38,8 @@ func EditMessage(event models.Event, body models.EventMessageBody) (models.Event
}
func DeleteMessage(event models.Event) (models.Event, error) {
_, err := DeleteEvent(event)
clonedEvent := event
_, err := DeleteEvent(clonedEvent)
if err != nil {
return event, err
}