mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-04 19:13:39 +00:00
Add transaction id to roomserver output API
This commit is contained in:
parent
7f6997effb
commit
f9f5880376
3 changed files with 15 additions and 8 deletions
|
@ -107,6 +107,9 @@ type OutputNewRoomEvent struct {
|
|||
// We encode the server name that the event should be sent using here to
|
||||
// future proof the API for virtual hosting.
|
||||
SendAsServer string `json:"send_as_server"`
|
||||
// The transaction ID of the send request if sent by a local user and one
|
||||
// was specified
|
||||
TransactionID *TransactionID `json:"transaction_id"`
|
||||
}
|
||||
|
||||
// An OutputNewInviteEvent is written whenever an invite becomes active.
|
||||
|
|
|
@ -129,7 +129,7 @@ func processRoomEvent(
|
|||
}
|
||||
|
||||
// Update the extremities of the event graph for the room
|
||||
return updateLatestEvents(ctx, db, ow, roomNID, stateAtEvent, event, input.SendAsServer)
|
||||
return updateLatestEvents(ctx, db, ow, roomNID, stateAtEvent, event, input.SendAsServer, input.TransactionID)
|
||||
}
|
||||
|
||||
func processInviteEvent(
|
||||
|
|
|
@ -50,6 +50,7 @@ func updateLatestEvents(
|
|||
stateAtEvent types.StateAtEvent,
|
||||
event gomatrixserverlib.Event,
|
||||
sendAsServer string,
|
||||
transactionID *api.TransactionID,
|
||||
) (err error) {
|
||||
updater, err := db.GetLatestEventsForUpdate(ctx, roomNID)
|
||||
if err != nil {
|
||||
|
@ -61,6 +62,7 @@ func updateLatestEvents(
|
|||
u := latestEventsUpdater{
|
||||
ctx: ctx, db: db, updater: updater, ow: ow, roomNID: roomNID,
|
||||
stateAtEvent: stateAtEvent, event: event, sendAsServer: sendAsServer,
|
||||
transactionID: transactionID,
|
||||
}
|
||||
if err = u.doUpdateLatestEvents(); err != nil {
|
||||
return err
|
||||
|
@ -75,13 +77,14 @@ func updateLatestEvents(
|
|||
// The state could be passed using function arguments, but it becomes impractical
|
||||
// when there are so many variables to pass around.
|
||||
type latestEventsUpdater struct {
|
||||
ctx context.Context
|
||||
db RoomEventDatabase
|
||||
updater types.RoomRecentEventsUpdater
|
||||
ow OutputRoomEventWriter
|
||||
roomNID types.RoomNID
|
||||
stateAtEvent types.StateAtEvent
|
||||
event gomatrixserverlib.Event
|
||||
ctx context.Context
|
||||
db RoomEventDatabase
|
||||
updater types.RoomRecentEventsUpdater
|
||||
ow OutputRoomEventWriter
|
||||
roomNID types.RoomNID
|
||||
stateAtEvent types.StateAtEvent
|
||||
event gomatrixserverlib.Event
|
||||
transactionID *api.TransactionID
|
||||
// Which server to send this event as.
|
||||
sendAsServer string
|
||||
// The eventID of the event that was processed before this one.
|
||||
|
@ -241,6 +244,7 @@ func (u *latestEventsUpdater) makeOutputNewRoomEvent() (*api.OutputEvent, error)
|
|||
Event: u.event,
|
||||
LastSentEventID: u.lastEventIDSent,
|
||||
LatestEventIDs: latestEventIDs,
|
||||
TransactionID: u.transactionID,
|
||||
}
|
||||
|
||||
var stateEventNIDs []types.EventNID
|
||||
|
|
Loading…
Reference in a new issue