mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 17:33:09 -06:00
Prevent duplicate events from being sent...
* Strip event content if it doesn't contain anything Signed-off-by: Andrew Morgan <andrewm@matrix.org>
This commit is contained in:
parent
17273aa547
commit
945c48eb47
|
|
@ -50,7 +50,7 @@ func SetupAppServiceAPIComponent(
|
|||
// a sync.Cond object that can be used to notify workers when there are new
|
||||
// events to be sent out.
|
||||
workerStates := make([]types.ApplicationServiceWorkerState, len(base.Cfg.Derived.ApplicationServices))
|
||||
for _, appservice := range base.Cfg.Derived.ApplicationServices {
|
||||
for i, appservice := range base.Cfg.Derived.ApplicationServices {
|
||||
eventCount := 0
|
||||
|
||||
m := sync.Mutex{}
|
||||
|
|
@ -59,7 +59,7 @@ func SetupAppServiceAPIComponent(
|
|||
Cond: sync.NewCond(&m),
|
||||
EventsReady: &eventCount,
|
||||
}
|
||||
workerStates = append(workerStates, ws)
|
||||
workerStates[i] = ws
|
||||
}
|
||||
|
||||
consumer := consumers.NewOutputRoomEventConsumer(
|
||||
|
|
|
|||
|
|
@ -116,6 +116,10 @@ func (s *OutputRoomEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
|||
}
|
||||
|
||||
// Check if any events need to passed on to external application services
|
||||
if len(events) > 0 {
|
||||
// Check if this was a membership event
|
||||
return s.filterRoomserverEvents(ctx, events)
|
||||
}
|
||||
return s.filterRoomserverEvents(ctx, append(events, ev))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ func (s *eventsStatements) insertEvent(
|
|||
appServiceID string,
|
||||
event *gomatrixserverlib.Event,
|
||||
) (err error) {
|
||||
// If event has no content, strip the json
|
||||
content := event.Content()
|
||||
if string(content) == "{\"disable\":true}" {
|
||||
content = []byte("{}")
|
||||
}
|
||||
|
||||
_, err = s.insertEventStmt.ExecContext(
|
||||
ctx,
|
||||
appServiceID,
|
||||
|
|
@ -218,7 +224,7 @@ func (s *eventsStatements) insertEvent(
|
|||
event.RoomID(),
|
||||
event.Type(),
|
||||
event.Sender(),
|
||||
event.Content(),
|
||||
content,
|
||||
-1, // No transaction ID yet
|
||||
)
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue