Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge commit '1bca21e1d' into anoa/dinsic_release_1_18_x
Browse files Browse the repository at this point in the history
* commit '1bca21e1d':
  Include room states on invite events sent to ASes (#6455)
  • Loading branch information
anoadragon453 committed Aug 4, 2020
2 parents ab98006 + 1bca21e commit cf30af5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/6455.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include room states on invite events that are sent to application services. Contributed by @Sorunome.
20 changes: 16 additions & 4 deletions synapse/appservice/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from twisted.internet import defer

from synapse.api.constants import ThirdPartyEntityKind
from synapse.api.constants import EventTypes, ThirdPartyEntityKind
from synapse.api.errors import CodeMessageException
from synapse.events.utils import serialize_event
from synapse.http.client import SimpleHttpClient
Expand Down Expand Up @@ -207,7 +207,7 @@ def push_bulk(self, service, events, txn_id=None):
if service.url is None:
return True

events = self._serialize(events)
events = self._serialize(service, events)

if txn_id is None:
logger.warning(
Expand All @@ -233,6 +233,18 @@ def push_bulk(self, service, events, txn_id=None):
failed_transactions_counter.labels(service.id).inc()
return False

def _serialize(self, events):
def _serialize(self, service, events):
time_now = self.clock.time_msec()
return [serialize_event(e, time_now, as_client_event=True) for e in events]
return [
serialize_event(
e,
time_now,
as_client_event=True,
is_invite=(
e.type == EventTypes.Member
and e.membership == "invite"
and service.is_interested_in_user(e.state_key)
),
)
for e in events
]

0 comments on commit cf30af5

Please sign in to comment.