Sorunome / mx-puppet-bridge

Puppeting library for matrix
Apache License 2.0
95 stars 29 forks source link

Pupetting multiple users that sit on the same matrix server fails #109

Open Mai-Lapyst opened 11 months ago

Mai-Lapyst commented 11 months ago

Hi; trying to setup an xmpp bridge (using https://github.com/ilvar/mx-puppet-xmpp). When one has multiple (in my case two) users on the same matrix homeserver / bridge setup that both which to link their xmpp accounts to their matrix account and then want to write over the xmpp bridge, it fails.

The bridge correctly creates the bridged room for user 1, but not for user 2. The logs state that the message is recieved but blocked: Found some puppet with puppetId=2. block=true.

I guess the problem is this block of code, since it contains a bug where it always uses the first available puppet, and uses that to determine if it needs to be blocked: https://github.com/Sorunome/mx-puppet-bridge/blob/559c8e11db93a36b638d9cf456e2c6d5a218b1c6/src/namespacehandler.ts#L514-L527

Sep-17 03:58:05.035 [NamespaceHandler] debug: In global namespace, determining if it should be blocked... puppetId=2 userId=BBBB roomId=BBBB
Sep-17 03:58:05.072 [NamespaceHandler] debug: Found some puppet with puppetId=2. block=false

...

Sep-17 04:13:11.641 [NamespaceHandler] debug: In global namespace, determining if it should be blocked... puppetId=3 userId=AAAA roomId=AAAA
Sep-17 04:13:11.645 [NamespaceHandler] debug: Found some puppet with puppetId=2. block=true

Notes:

More log ``` Sep-17 03:58:05.035 [NamespaceHandler] debug: In global namespace, determining if it should be blocked... puppetId=2 userId=BBBB roomId=BBBB Sep-17 03:58:05.035 [Postgres] silly: All: SELECT * FROM puppet_store Sep-17 03:58:05.070 [XmppPuppet:xmpp] info: getUserIdsInRoom { puppetId: 2, roomId: 'BBBB' } Sep-17 03:58:05.070 [XmppPuppet:client] info: Fetching conversation { puppetId: 2, roomId: 'BBBB' } Sep-17 03:58:05.070 [XmppPuppet:client] info: Fetching conversation puppetId=2 roomId=BBBB Sep-17 03:58:05.071 [XmppPuppet:client] info: Returning cached result Sep-17 03:58:05.071 [XmppPuppet:client] silly: { id: 'BBBB', members: [] } Sep-17 03:58:05.071 [XmppPuppet:xmpp] info: getUserIdsInRoom users Set {} Sep-17 03:58:05.072 [XmppPuppet:xmpp] info: Received create request for channel update puppetId=2 roomId=BBBB Sep-17 03:58:05.072 [XmppPuppet:client] info: Fetching conversation { puppetId: 2, roomId: 'BBBB' } Sep-17 03:58:05.072 [XmppPuppet:client] info: Fetching conversation puppetId=2 roomId=BBBB Sep-17 03:58:05.072 [XmppPuppet:client] info: Returning cached result Sep-17 03:58:05.072 [XmppPuppet:client] silly: { id: 'BBBB', members: [] } Sep-17 03:58:05.072 [NamespaceHandler] debug: Found some puppet with puppetId=2. block=false ... Sep-17 04:13:11.641 [NamespaceHandler] debug: In global namespace, determining if it should be blocked... puppetId=3 userId=AAAA roomId=AAAA Sep-17 04:13:11.641 [XmppPuppet:xmpp] info: getUserIdsInRoom { puppetId: 2, roomId: 'AAAA' } Sep-17 04:13:11.641 [XmppPuppet:client] info: Fetching conversation { puppetId: 2, roomId: 'AAAA' } Sep-17 04:13:11.642 [XmppPuppet:client] info: Fetching conversation puppetId=2 roomId=AAAA Sep-17 04:13:11.642 [XmppPuppet:client] info: Returning cached result Sep-17 04:13:11.642 [XmppPuppet:client] silly: { id: 'AAAA', members: [] } Sep-17 04:13:11.642 [XmppPuppet:xmpp] info: getUserIdsInRoom users Set {} Sep-17 04:13:11.642 [XmppPuppet:xmpp] info: getUserIdsInRoom { puppetId: 3, roomId: 'AAAA' } Sep-17 04:13:11.643 [XmppPuppet:client] info: Fetching conversation { puppetId: 3, roomId: 'AAAA' } Sep-17 04:13:11.643 [XmppPuppet:client] info: Fetching conversation puppetId=3 roomId=AAAA Sep-17 04:13:11.643 [XmppPuppet:client] info: Returning cached result Sep-17 04:13:11.643 [XmppPuppet:client] silly: { id: 'AAAA', members: [] } Sep-17 04:13:11.643 [XmppPuppet:xmpp] info: getUserIdsInRoom users Set {} Sep-17 04:13:11.643 [XmppPuppet:xmpp] info: Received create request for channel update puppetId=2 roomId=AAAA Sep-17 04:13:11.644 [XmppPuppet:client] info: Fetching conversation { puppetId: 2, roomId: 'AAAA' } Sep-17 04:13:11.644 [XmppPuppet:client] info: Fetching conversation puppetId=2 roomId=AAAA Sep-17 04:13:11.644 [XmppPuppet:client] info: Returning cached result Sep-17 04:13:11.644 [XmppPuppet:client] silly: { id: 'AAAA', members: [] } Sep-17 04:13:11.644 [XmppPuppet:xmpp] info: Received create request for channel update puppetId=3 roomId=AAAA Sep-17 04:13:11.645 [XmppPuppet:client] info: Fetching conversation { puppetId: 3, roomId: 'AAAA' } Sep-17 04:13:11.645 [XmppPuppet:client] info: Fetching conversation puppetId=3 roomId=AAAA Sep-17 04:13:11.645 [XmppPuppet:client] info: Returning cached result Sep-17 04:13:11.645 [XmppPuppet:client] silly: { id: 'AAAA', members: [] } Sep-17 04:13:11.645 [NamespaceHandler] debug: Found some puppet with puppetId=2. block=true ```