matrix-org / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://matrix-org.github.io/dendrite/
Apache License 2.0
5.75k stars 676 forks source link

App Service doesn't send events for the appservice's own user ID #1871

Closed adamgreig closed 2 years ago

adamgreig commented 3 years ago

Background information

Description

I'm running the heisenbridge app service with dendrite. Heisenbridge expects to receive events to its transactions endpoint that relate to its own appservice user, @heisenbridge:example.org, for example invitations to a room. In Synapse, events are sent to an app service if they match a users namespace regex or if they relate to the appservice user ID:

https://github.com/matrix-org/synapse/blob/4b965c862dc66c0da5d3240add70e9b5f0aa720b/synapse/appservice/__init__.py#L263

However, in dendrite, only events relating to users matching a namespace regex are sent, and not events about the appservice user itself:

https://github.com/matrix-org/dendrite/blob/2c9a390fa67aa80bd8cfffb02b20739d0b1807d8/setup/config/config_appservice.go#L113-L127

https://github.com/matrix-org/dendrite/blob/2c9a390fa67aa80bd8cfffb02b20739d0b1807d8/clientapi/routing/getevent.go#L117-L120

As a workaround, I can add the appservices' own user ID as a users namespace, and it then receives these events and functions correctly. I can't tell from the API specification which is the expected behaviour.

kegsay commented 3 years ago

It should be sending you events for the AS user without having to add it to the regexp.

Half-Shot commented 3 years ago

Allegedly this was fixed in https://github.com/matrix-org/dendrite/pull/1790

nkitsaini commented 3 years ago

I've noticed this bug today, while trying to setup a bridge. Inviting the bridge namespace users (@_gmail_bridge_some_:jif.one) will send the event to bridge but if Appservice user itself (@gmail:jif.one) is invited then no event can be seen.

time="2021-09-16T03:16:41.945234208Z" level=info msg="processing invite event" func="PerformInvite\n\t" file=" [perform_invite.go:63]" event_id="$WPMZqcapBz7xMpQTb6RL31AxU7LC0EcXPlXeXbOBoj4" room_id="!P4r0MeZriuFqeM0B:jif.one" room_info_exists=true room_version=6 target_user_id="@gmail:jif.one"
time="2021-09-16T03:16:42.031513195Z" level=info msg="Producing to topic 'DendriteOutputRoomEvent'" func="WriteOutputEvents\n\t" file=" [input.go:130]" room_id="!P4r0MeZriuFqeM0B:jif.one" type=new_invite_event
time="2021-09-16T03:16:42.031876446Z" level=info msg="Producing to topic 'DendriteOutputRoomEvent'" func="WriteOutputEvents\n\t" file=" [input.go:130]" adds_state=1 content_value=invite event_id="$WPMZqcapBz7xMpQTb6RL31AxU7LC0EcXPlXeXbOBoj4" event_type=m.room.member removes_state=0 room_id="!P4r0MeZriuFqeM0B:jif.one" send_as_server=jif.one sender="@my_test:jif.one" state_key="@gmail:jif.one" type=new_room_event
time="2021-09-16T03:16:42.040887953Z" level=debug msg="roomserver output log: ignoring unknown output type" func="onMessage\n\t" file=" [roomserver.go:126]" type=new_invite_event
time="2021-09-16T03:16:42.050274406Z" level=info msg="Federation disabled" func="onMessage\n\t" file=" [roomserver.go:102]" error=new_room_event
time="2021-09-16T03:16:42.063717212Z" level=debug msg="Responding to sync after wake-up" func="OnIncomingSyncRequest\n\t" file=" [requestpool.go:182]" device_id=KINcrGGb limit=20 req.id=HzVAUoOYZKXG req.method=GET req.path=/_matrix/client/r0/sync since=s71_6_6_0_16_19.dl-0-8 timeout=30s user_id="@my_test:jif.one"
time="2021-09-16T03:16:42.070358158Z" level=debug msg="QueryKeyChanges request p=0,off=8,to=8 response p=0 off=8 uids=[]" func="DeviceListCatchup\n\t" file=" [keychange.go:98]" context=missing
time="2021-09-16T03:16:42.433768941Z" level=info msg="Producing to topic 'DendriteOutputClientData'" func="SendData\n\t" file=" [syncapi.go:51]" data_type=m.fully_read room_id="!P4r0MeZriuFqeM0B:jif.one" user_id="@my_test:jif.one"
time="2021-09-16T03:16:42.483318609Z" level=info msg="received data from client API server" func="onMessage\n\t" file=" [clientapi.go:89]" room_id="!P4r0MeZriuFqeM0B:jif.one" type=m.fully_read
time="2021-09-16T03:16:42.488950349Z" level=debug msg="Responding to sync after wake-up" func="OnIncomingSyncRequest\n\t" file=" [requestpool.go:182]" device_id=KINcrGGb limit=20 req.id=lACS5eBoYovA req.method=GET req.path=/_matrix/client/r0/sync since=s72_6_6_0_17_19.dl-0-8 timeout=30s user_id="@my_test:jif.one"
time="2021-09-16T03:16:42.548573930Z" level=debug msg="QueryKeyChanges request p=0,off=8,to=8 response p=0 off=8 uids=[]" func="DeviceListCatchup\n\t" file=" [keychange.go:98]" context=missing

If helpful, these are the debug logs from docker container. I've tried following things:

Let me know if any extra information will be helpful.

NickCao commented 2 years ago

Same here, adding appservice itself to the registration file works.