mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
PDU Sender split (#3100)
Initial cut of splitting PDU Sender into SenderID & looking up UserID where required.
This commit is contained in:
parent
725ff5567d
commit
7a1fd7f512
66 changed files with 580 additions and 189 deletions
|
@ -343,7 +343,7 @@ func (s *currentRoomStateStatements) UpsertRoomState(
|
|||
event.RoomID(),
|
||||
event.EventID(),
|
||||
event.Type(),
|
||||
event.Sender(),
|
||||
event.SenderID(),
|
||||
containsURL,
|
||||
*event.StateKey(),
|
||||
headeredJSON,
|
||||
|
|
|
@ -407,7 +407,7 @@ func (s *outputRoomEventsStatements) InsertEvent(
|
|||
event.EventID(),
|
||||
headeredJSON,
|
||||
event.Type(),
|
||||
event.Sender(),
|
||||
event.SenderID(),
|
||||
containsURL,
|
||||
pq.StringArray(addState),
|
||||
pq.StringArray(removeState),
|
||||
|
|
|
@ -195,7 +195,21 @@ func (d *Database) StreamEventsToEvents(device *userapi.Device, in []types.Strea
|
|||
for i := 0; i < len(in); i++ {
|
||||
out[i] = in[i].HeaderedEvent
|
||||
if device != nil && in[i].TransactionID != nil {
|
||||
if device.UserID == in[i].Sender() && device.SessionID == in[i].TransactionID.SessionID {
|
||||
userID, err := spec.NewUserID(device.UserID, true)
|
||||
if err != nil {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"event_id": out[i].EventID(),
|
||||
}).WithError(err).Warnf("Failed to add transaction ID to event")
|
||||
continue
|
||||
}
|
||||
deviceSenderID, err := d.getSenderIDForUser(in[i].RoomID(), *userID)
|
||||
if err != nil {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"event_id": out[i].EventID(),
|
||||
}).WithError(err).Warnf("Failed to add transaction ID to event")
|
||||
continue
|
||||
}
|
||||
if deviceSenderID == in[i].SenderID() && device.SessionID == in[i].TransactionID.SessionID {
|
||||
err := out[i].SetUnsignedField(
|
||||
"transaction_id", in[i].TransactionID.TransactionID,
|
||||
)
|
||||
|
@ -210,6 +224,11 @@ func (d *Database) StreamEventsToEvents(device *userapi.Device, in []types.Strea
|
|||
return out
|
||||
}
|
||||
|
||||
func (d *Database) getSenderIDForUser(roomID string, userID spec.UserID) (string, error) { // nolint
|
||||
// TODO: Repalce with actual logic for pseudoIDs
|
||||
return userID.String(), nil
|
||||
}
|
||||
|
||||
// handleBackwardExtremities adds this event as a backwards extremity if and only if we do not have all of
|
||||
// the events listed in the event's 'prev_events'. This function also updates the backwards extremities table
|
||||
// to account for the fact that the given event is no longer a backwards extremity, but may be marked as such.
|
||||
|
|
|
@ -342,7 +342,7 @@ func (s *currentRoomStateStatements) UpsertRoomState(
|
|||
event.RoomID(),
|
||||
event.EventID(),
|
||||
event.Type(),
|
||||
event.Sender(),
|
||||
event.SenderID(),
|
||||
containsURL,
|
||||
*event.StateKey(),
|
||||
headeredJSON,
|
||||
|
|
|
@ -348,7 +348,7 @@ func (s *outputRoomEventsStatements) InsertEvent(
|
|||
event.EventID(),
|
||||
headeredJSON,
|
||||
event.Type(),
|
||||
event.Sender(),
|
||||
event.SenderID(),
|
||||
containsURL,
|
||||
string(addStateJSON),
|
||||
string(removeStateJSON),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue