🗃️ Add relations between related event and original event
This commit is contained in:
parent
6c60e250e1
commit
c642f5ee44
@ -63,6 +63,7 @@ func newMessageEvent(c *fiber.Ctx) error {
|
||||
Sender: member,
|
||||
Channel: channel,
|
||||
QuoteEventID: data.Body.QuoteEventID,
|
||||
RelatedEventID: data.Body.RelatedEventID,
|
||||
ChannelID: channel.ID,
|
||||
SenderID: member.ID,
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ type Event struct {
|
||||
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"`
|
||||
}
|
||||
@ -33,6 +35,6 @@ type EventMessageBody struct {
|
||||
Algorithm string `json:"algorithm,omitempty"`
|
||||
Attachments []string `json:"attachments,omitempty"`
|
||||
QuoteEventID *uint `json:"quote_event,omitempty"`
|
||||
RelatedEvent *uint `json:"related_event,omitempty"`
|
||||
RelatedEventID *uint `json:"related_event,omitempty"`
|
||||
RelatedUsers []uint `json:"related_users,omitempty"`
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func EditMessage(event models.Event, body models.EventMessageBody) (models.Event
|
||||
if err != nil {
|
||||
return event, err
|
||||
}
|
||||
body.RelatedEvent = &event.ID
|
||||
body.RelatedEventID = &event.ID
|
||||
_, err = NewEvent(models.Event{
|
||||
Uuid: uuid.NewString(),
|
||||
Body: EncodeMessageBody(body),
|
||||
@ -27,6 +27,7 @@ func EditMessage(event models.Event, body models.EventMessageBody) (models.Event
|
||||
Channel: event.Channel,
|
||||
Sender: event.Sender,
|
||||
QuoteEventID: body.QuoteEventID,
|
||||
RelatedEventID: body.RelatedEventID,
|
||||
ChannelID: event.ChannelID,
|
||||
SenderID: event.SenderID,
|
||||
})
|
||||
@ -45,11 +46,12 @@ func DeleteMessage(event models.Event) (models.Event, error) {
|
||||
_, err = NewEvent(models.Event{
|
||||
Uuid: uuid.NewString(),
|
||||
Body: EncodeMessageBody(models.EventMessageBody{
|
||||
RelatedEvent: &event.ID,
|
||||
RelatedEventID: &event.ID,
|
||||
}),
|
||||
Type: models.EventMessageDelete,
|
||||
Channel: event.Channel,
|
||||
Sender: event.Sender,
|
||||
RelatedEventID: &event.ID,
|
||||
ChannelID: event.ChannelID,
|
||||
SenderID: event.SenderID,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user