GithubHelp home page GithubHelp logo

mautrix / googlechat Goto Github PK

View Code? Open in Web Editor NEW
112.0 12.0 32.0 1.14 MB

A Matrix-Google Chat puppeting bridge

Home Page: https://matrix.to/#/#googlechat:maunium.net

License: GNU Affero General Public License v3.0

Dockerfile 0.18% Python 99.65% Shell 0.17%
matrix-org matrix-appservice python matrix bridge google-chat

googlechat's Introduction

googlechat's People

Contributors

cadair avatar durin42 avatar ericmigi avatar fizzadar avatar grimmy avatar pastudan avatar pmzuk avatar rihardsk avatar sumnerevans avatar surakin avatar tulir avatar wolfpld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googlechat's Issues

Syntax error on startup

Using latest as of this ticket.

Oct 24 22:42:02 integrations systemd[1]: Started Hangouts Bridge.
Oct 24 22:42:03 integrations python[19770]: Traceback (most recent call last):
Oct 24 22:42:03 integrations python[19770]:   File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
Oct 24 22:42:03 integrations python[19770]:     "__main__", mod_spec)
Oct 24 22:42:03 integrations python[19770]:   File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
Oct 24 22:42:03 integrations python[19770]:     exec(code, run_globals)
Oct 24 22:42:03 integrations python[19770]:   File "/home/hangouts/hgenv/lib/python3.6/site-packages/mautrix_hangouts/__main__.py", line 23, in <module>
Oct 24 22:42:03 integrations python[19770]:     from .sqlstatestore import SQLStateStore
Oct 24 22:42:03 integrations python[19770]:   File "/home/hangouts/hgenv/lib/python3.6/site-packages/mautrix_hangouts/sqlstatestore.py", line 19, in <module>
Oct 24 22:42:03 integrations python[19770]:     from . import puppet as pu
Oct 24 22:42:03 integrations python[19770]:   File "/home/hangouts/hgenv/lib/python3.6/site-packages/mautrix_hangouts/puppet.py", line 31, in <module>
Oct 24 22:42:03 integrations python[19770]:     from . import user as u, portal as p, matrix as m
Oct 24 22:42:03 integrations python[19770]:   File "/home/hangouts/hgenv/lib/python3.6/site-packages/mautrix_hangouts/user.py", line 39, in <module>
Oct 24 22:42:03 integrations python[19770]:     from . import puppet as pu, portal as po
Oct 24 22:42:03 integrations python[19770]:   File "/home/hangouts/hgenv/lib/python3.6/site-packages/mautrix_hangouts/portal.py", line 400
Oct 24 22:42:03 integrations python[19770]:     async def process_hangouts_attachments(self, event: ChatMessageEvent, intent: IntentAPI)
Oct 24 22:42:03 integrations python[19770]:                                                                                            ^
Oct 24 22:42:03 integrations python[19770]: SyntaxError: invalid syntax
Oct 24 22:42:03 integrations systemd[1]: hangouts.service: Main process exited, code=exited, status=1/FAILURE

Add relay bot support

Would be the first step in allowing people to use the bridge to migrate away from hangouts. What would need doing to enable this and I might take a crack at it.

Bridge doesn't start after upgrade to 0.1.2 - AttributeError: '_Union' object has no attribute 'deserialize'

After Upgrading the bridge to the latest version following error appears when try to start or upgrade the bridge

Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix_hangouts/__main__.py", line 16, in <module>
    from mautrix.bridge import Bridge
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/bridge/__init__.py", line 2, in <module>
    from .custom_puppet import CustomPuppetMixin, CustomPuppetError, OnlyLoginSelf, InvalidAccessToken
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/bridge/custom_puppet.py", line 17, in <module>
    from mautrix.types import (UserID, FilterID, Filter, RoomEventFilter, RoomFilter, EventFilter,
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/types/__init__.py", line 3, in <module>
    from .filter import Filter, EventFilter, RoomFilter, StateFilter, RoomEventFilter
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/types/filter.py", line 10, in <module>
    from .event import EventType
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/types/event/__init__.py", line 15, in <module>
    from .state import (PowerLevelStateEventContent, Membership, MemberStateEventContent, StateEvent,
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/types/event/state.py", line 13, in <module>
    from .encrypted import EncryptionAlgorithm
  File "/opt/mautrix-hangouts/lib/python3.6/site-packages/mautrix/types/event/encrypted.py", line 89, in <module>
    setattr(EncryptedEventContent, "deserialize", deserialize_encrypted)
AttributeError: '_Union' object has no attribute 'deserialize'

Any Idea what I should do?

I tried to adapt the config to the latest example config, so that no parameters are missing, which should now be the case.
I'm not trying to use bridge encryption, if that helps

Cannot login without pressing "Start" twice on the portal

Error:

[2019-05-14 01:15:21,623] [[email protected]] 127.0.0.1 [14/May/2019:01:15:21 +0000] "POST /login/api/verify HTTP/1.0" 200 186 "https://hangouts.t2host.io/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
[2019-05-14 01:15:22,646] [[email protected]] Authenticating with refresh token
[2019-05-14 01:15:22,646] [[email protected]] Failed to authenticate using refresh token: Refresh token not found
[2019-05-14 01:15:22,646] [[email protected]] Authenticating with credentials
[2019-05-14 01:15:22,658] [[email protected]] Unhandled exception
Traceback (most recent call last):
  File "/home/hangouts/hgenv/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 447, in start
    await resp.prepare(request)
  File "/home/hangouts/hgenv/lib/python3.6/site-packages/aiohttp/web_response.py", line 353, in prepare
    return await self._start(request)
  File "/home/hangouts/hgenv/lib/python3.6/site-packages/aiohttp/web_response.py", line 667, in _start
    return await super()._start(request)
  File "/home/hangouts/hgenv/lib/python3.6/site-packages/aiohttp/web_response.py", line 410, in _start
    await writer.write_headers(status_line, headers)
  File "/home/hangouts/hgenv/lib/python3.6/site-packages/aiohttp/http_writer.py", line 112, in write_headers
    self._write(buf)
  File "/home/hangouts/hgenv/lib/python3.6/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

Invalid URL: host is required for absolute urls

Attempting to use a config like:

appservice:
  database: postgres://mautrix-googlechat@/mautrix_googlechat

Now results in the following failure:

mautrix-googlechat[685955]:   File "/lib/python3.9/site-packages/mautrix/bridge/bridge.py", line 168, in prepare_db
mautrix-googlechat[685955]:     self.db = Database.create(
mautrix-googlechat[685955]:   File "/lib/python3.9/site-packages/mautrix/util/async_db/database.py", line 66, in create
mautrix-googlechat[685955]:     url = URL(url)
mautrix-googlechat[685955]:   File "/lib/python3.9/site-packages/yarl/_url.py", line 167, in __new__
mautrix-googlechat[685955]:     raise ValueError("Invalid URL: host is required for absolute urls")

Previously (on bafd1f7 with mautrix-python 0.14) this worked as expected. As far as I know, using an empty host is the only/standard way to indicate connection via local unix socket path rather than connecting over tcp, so I'm not sure what alternatives are meant to be used here?

This can be worked around by finding the actual socket path, and uri-encoding it into the host like postgres://mautrix-googlechat@%2Frun%2Fpostgresql/mautrix_googlechat

(this may actually be a mautrix-python issue, I'm not sure, should it be moved?)

Read reciepts are not actually sent toward hangouts

The features checklist mentions Matrix โ†’ Hangouts / [x] Read receipts.

But I don't think this is working:

Whenever I read a recieved hangouts message from matrix, while my matrix client will have "seen" the message (matrix room no longer bolded), I don't see the same for the my avatar from hangouts (no Seen by $MyName (Hangouts) (@hangouts_5454543:example.com)).

If i load up the official hangouts, the room that I just "seen" in matrix is still bolded. My hangout friends will always think I never read their messages, despite sometimes replying.

If I "read" the new message there it will of course unbold itself in hangouts. And then in matrix I also notice my hangouts avatar update its read reciept. Seen by $MyName (Hangouts) (@hangouts_5454543:example.com) moves the last message.

Read reciepts seem to work perfectly fine toward matrix, but they don't really work toward hangouts. It's as if Seen by $MyName should perfectly follow my matrix user that it's representing.

Matrix -> Gchat pinging does not work

When messaging in in a gchat space using Matrix, I select a person as @<name> (googlechat) hoping that the person would get notified in the official gchat client. But what appears in the official gchat client is just a plain text <name> (googlechat) and the person is not notified.

Some chats fail to backfill properly

I tried to let the bridge backfill some old chats by leaving an existing room, and restarting the bridge, so it would pick up the initial sync again. Currently this fails with the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 509, in ensure_joined
    await self.join_room(room_id, max_retries=0)
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 123, in wrapper
    return await __method(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/mautrix/client/store_updater.py", line 62, in join_room
    room_id = await super().join_room(
  File "/usr/lib/python3.9/site-packages/mautrix/client/api/rooms.py", line 320, in join_room
    content = await self.api.request(
  File "/usr/lib/python3.9/site-packages/mautrix/api.py", line 376, in request
    return await self._send(method, full_url, req_content, query_params, headers or {})
  File "/usr/lib/python3.9/site-packages/mautrix/api.py", line 255, in _send
    raise make_request_error(
mautrix.errors.request.MForbidden: You are not invited to this room.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 509, in ensure_joined
    await self.join_room(room_id, max_retries=0)
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 123, in wrapper
    return await __method(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/mautrix/client/store_updater.py", line 62, in join_room
    room_id = await super().join_room(
  File "/usr/lib/python3.9/site-packages/mautrix/client/api/rooms.py", line 320, in join_room
    content = await self.api.request(
  File "/usr/lib/python3.9/site-packages/mautrix/api.py", line 376, in request
    return await self._send(method, full_url, req_content, query_params, headers or {})
  File "/usr/lib/python3.9/site-packages/mautrix/api.py", line 255, in _send
    raise make_request_error(
mautrix.errors.request.MForbidden: You are not invited to this room.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mautrix_googlechat/portal.py", line 319, in backfill
    total_handled = await self._initial_backfill(source)
  File "/usr/lib/python3.9/site-packages/mautrix_googlechat/portal.py", line 353, in _initial_backfill
    await self.handle_googlechat_message(source, topic.replies[0])
  File "/usr/lib/python3.9/site-packages/mautrix_googlechat/portal.py", line 1209, in handle_googlechat_message
    event_id = await self._send_message(intent, content, timestamp=timestamp)
  File "/usr/lib/python3.9/site-packages/mautrix/bridge/portal.py", line 424, in _send_message
    return await intent.send_message_event(self.mxid, event_type, content, **kwargs)
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 134, in wrapper
    await __self.ensure_joined(room_id)
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 515, in ensure_joined
    await bot.invite_user(room_id, self.mxid)
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 134, in wrapper
    await __self.ensure_joined(room_id)
  File "/usr/lib/python3.9/site-packages/mautrix/appservice/api/intent.py", line 513, in ensure_joined
    raise IntentError(f"Failed to join room {room_id} as {self.mxid}") from e
mautrix.errors.base.IntentError: Failed to join room !egLgZGAerfYlIvMZdS:sonck.nl as @googlechatbot:sonck.nl

Direct chats with bots do not get bridged correctly.

In a private g/chat room with only yourself and a bot (say a webhook notification bot updating you on incident details from a ticketing system) this works fine in the g/chat interface however the bot chat never appears in the bridged room.

bridge sending way too many typing status updates

Anthony's hangouts bridge is sending tons and tons of typing updates when he types

[2020-04-25 06:03:11,445] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:11,549] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:11,795] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:12,093] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:12,126] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:12,311] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:12,682] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:12,747] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:12,909] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:13,249] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:13,319] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:13,397] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:13,449] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:13,593] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:13,960] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:14,018] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:14,208] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:14,254] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:14,507] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:14,565] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:14,771] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:14,903] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:15,127] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:15,278] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}                
[2020-04-25 06:03:15,490] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000$
[2020-04-25 06:03:15,494] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:15,827] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}
[2020-04-25 06:03:15,902] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}
[2020-04-25 06:03:16,047] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:16,103] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:16,128] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": true, "timeout": 6000}
[2020-04-25 06:03:16,372] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}
[2020-04-25 06:03:16,474] [[email protected].@anthony:nova.chat] PUT /_matrix/client/r0/rooms/%21OrPDjwqjceOtCEfjlw%3Anova.chat/typing/%40anthony%3Anova.chat {"typing": false}

Timeout when submitting oauth_code

When trying to authenticate using the current docker image (as of this submission), I experience a long delay when submitting the oauth_code value, and ultimately a failure.

After this error the docker image becomes unresponsive and has to be restarted.

I should note that I am using a Google account that is a Google Workspace (custom domain).

Docker log details:

[2021-09-18 04:21:24,037] [[email protected]] 172.18.0.3 [18/Sep/2021:04:21:24 +0000] "PUT /transactions/29?access_token=TOKEN_REMOVED HTTP/1.1" 200 158 "-" "Synapse/1.42.0"
[2021-09-18 04:21:25,923] [[email protected]] 172.18.0.1 [18/Sep/2021:04:21:25 +0000] "POST /login/api/verify HTTP/1.1" 200 194 "https://matrix.domain.tld/mautrix-googlechat/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.41 Safari/537.36 Edg/94.0.992.19"
[2021-09-18 04:21:27,682] [[email protected]] 172.18.0.1 [18/Sep/2021:04:21:27 +0000] "POST /login/api/start HTTP/1.1" 200 470 "https://matrix.domain.tld/mautrix-googlechat/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.41 Safari/537.36 Edg/94.0.992.19"
[2021-09-18 04:26:59,387] [[email protected].@user:domain.tld] Exception in connection
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
    return await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/lib/python3.9/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/usr/lib/python3.9/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mautrix_googlechat/user.py", line 216, in start
    await self.client.connect()
  File "/usr/lib/python3.9/site-packages/hangups/client.py", line 150, in connect
    await self._listen_future
  File "/usr/lib/python3.9/site-packages/hangups/channel.py", line 179, in listen
    self._csessionid_param = await self._register()
  File "/usr/lib/python3.9/site-packages/hangups/channel.py", line 234, in _register
    res = await self._session.fetch_raw('POST', CHANNEL_URL_BASE + 'register', headers=headers)
  File "/usr/lib/python3.9/site-packages/hangups/http_utils.py", line 132, in fetch_raw
    return await resp
  File "/usr/lib/python3.9/site-packages/aiohttp/client.py", line 524, in _request
    raise ServerTimeoutError(
aiohttp.client_exceptions.ServerTimeoutError: Connection timeout to host https://chat.google.com/webchannel/register

Error log entry from nginx reverse proxy:

2021/09/18 04:32:07 [error] 10#10: *1848 upstream timed out (110: Operation timed out) while reading response header from upstream, client: address-removed, server: matrix.domain.tld, request: "POST /mautrix-googlechat/login/api/authorization HTTP/2.0", upstream: "http://address-removed:29320/login/api/authorization", host: "matrix.domain.tld", referrer: "https://matrix.domain.tld/mautrix-googlechat/login/"

Handle issues with postgres more gracefully

Last night I restarted the postgresql service for reasons... and it resulted in mautrix crashing. It would probably be better if there was some retry logic to recover from this, as I imagine the same scenario could happen if the postgres database were on a remote system and there was a network failure.

This also relates to #12 as it would have been nice if users all got a message from the bot while it was shutting down/starting back up.

Feb 27 03:39:50 archlinux mautrix-hangouts[53697]: [2020-02-27 03:39:50,813] [[email protected]] Client.connect returning because Channel.listen returned
Feb 27 03:39:50 archlinux mautrix-hangouts[53697]: [2020-02-27 03:39:50,813] [[email protected].@REDACTED:REDACTED] Client connection finished
i
Feb 27 03:39:50 archlinux mautrix-hangouts[53697]: [2020-02-27 03:39:50,814] [[email protected]] Stopping puppet syncers
Feb 27 03:39:50 archlinux mautrix-hangouts[53697]: [2020-02-27 03:39:50,814] [[email protected]] Saving user sessions
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: Traceback (most recent call last):
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1245, in _execute_context
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     self.dialect.do_execute(
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     cursor.execute(statement, parameters)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: psycopg2.errors.AdminShutdown: terminating connection due to administrator command
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: server closed the connection unexpectedly
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:         This probably means the server terminated abnormally
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:         before or while processing the request.
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: The above exception was the direct cause of the following exception:
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: Traceback (most recent call last):
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/bin/mautrix-hangouts", line 11, in <module>
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     load_entry_point('mautrix-hangouts==0.1.0.dev7+dev.1241db9b', 'console_scripts', 'mautrix-hangouts')()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     return get_distribution(dist).load_entry_point(group, name)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     return ep.load()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2445, in load
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     return self.resolve()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2451, in resolve
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     module = __import__(self.module_name, fromlist=['__name__'], level=0)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/mautrix_hangouts/__main__.py", line 78, in <module>
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     HangoutsBridge().run()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/mautrix/bridge/bridge.py", line 84, in run
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     self._run()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/mautrix/bridge/bridge.py", line 210, in _run
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     self.prepare_shutdown()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/mautrix_hangouts/__main__.py", line 75, in prepare_shutdown
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     user.save()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/mautrix_hangouts/user.py", line 92, in save
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     self.db_instance.edit(refresh_token=self.refresh_token, gid=self.gid)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/mautrix/util/db/base.py", line 157, in edit
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     conn.execute(self.t.update()
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 982, in execute
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     return meth(self, multiparams, params)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     return connection._execute_clauseelement(self, multiparams, params)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1095, in _execute_clauseelement
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     ret = self._execute_context(
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     self._handle_dbapi_exception(
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     util.raise_from_cause(sqlalchemy_exception, exc_info)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     reraise(type(exception), exception, tb=exc_tb, cause=cause)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     raise value.with_traceback(tb)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1245, in _execute_context
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     self.dialect.do_execute(
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:   File "/usr/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:     cursor.execute(statement, parameters)
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: sqlalchemy.exc.OperationalError: (psycopg2.errors.AdminShutdown) terminating connection due to administrator command
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: server closed the connection unexpectedly
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:         This probably means the server terminated abnormally
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]:         before or while processing the request.
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: [SQL: UPDATE "user" SET gid=%(gid)s, refresh_token=%(refresh_token)s WHERE "user".mxid = %(mxid_1)s]
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: [parameters: {'gid': 'REDACTED', 'refresh_token': 'REDACTED', 'mxid_1': '@REDACTED:REDACTED'}]
Feb 27 03:39:51 archlinux mautrix-hangouts[53697]: (Background on this error at: http://sqlalche.me/e/e3q8)
Feb 27 03:39:52 archlinux systemd[1]: mautrix-hangouts.service: Main process exited, code=exited, status=1/FAILURE
Feb 27 03:39:52 archlinux systemd[1]: mautrix-hangouts.service: Failed with result 'exit-code'.
Feb 27 03:39:52 archlinux systemd[1]: Stopped Hangouts Matrix Puppet.

Bridge fails to start

Hi,
after update, i get the following error:

systemd[1]: Started mautrix-hangouts.
python[322853]: Traceback (most recent call last):
python[322853]:   File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
python[322853]:     return _run_code(code, main_globals, None,
python[322853]:   File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
python[322853]:     exec(code, run_globals)
python[322853]:   File "/var/lib/synapse/mautrix-hangouts/mautrix_hangouts/__main__.py", line 22, in <module>
python[322853]:     from .sqlstatestore import SQLStateStore
python[322853]:   File "/var/lib/synapse/mautrix-hangouts/mautrix_hangouts/sqlstatestore.py", line 19, in <module>
python[322853]:     from . import puppet as pu
python[322853]:   File "/var/lib/synapse/mautrix-hangouts/mautrix_hangouts/puppet.py", line 31, in <module>
python[322853]:     from . import user as u, portal as p, matrix as m
python[322853]:   File "/var/lib/synapse/mautrix-hangouts/mautrix_hangouts/user.py", line 37, in <module>
python[322853]:     from .util.hangups_try_auth import try_auth, TryAuthResp
python[322853]:   File "/var/lib/synapse/mautrix-hangouts/mautrix_hangouts/util/__init__.py", line 1, in <module>
python[322853]:     from .color_log import ColorFormatter
python[322853]:   File "/var/lib/synapse/mautrix-hangouts/mautrix_hangouts/util/color_log.py", line 16, in <module>
python[322853]:     from mautrix.util.logging.color import ColorFormatter as BaseColorFormatter, PREFIX, RESET
python[322853]: ModuleNotFoundError: No module named 'mautrix.util.logging'
systemd[1]: mautrix-hangouts.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mautrix-hangouts.service: Failed with result 'exit-code'.

This is revision 29e5705, after following the usual update steps.
Any idea what's missing?

Failed to find form '#gaia_loginform' in page

Getting the error Login failed: Failed to find form '#gaia_loginform' in page after submitting the password to the login form.

Trying to follow the manual steps, I'm not seeing the oauth_code cookie in any of the accounts.google.com requests.

canonical_email should be part of the matrix usernames

I really think the google account usernames should be part of the matrix usernames, instead of the long (opaque) number.

What I have now: @hangouts_100121435454675246423:example.com, this might be hangups.user.UserID but i'm not sure.

What I want to have: @hangouts_somegaia_at_gmail.com:example.com. hangups.user.User.emails is probably what we should be using.

Perhaps this is related to issue #42.

Though, I'm not sure how migration would work though for chats I'm already in.

User's own messages are not backfilled without login-matrix

After Google login, mautrix-hangouts created Matrix rooms (without messages). After mautrix-hangouts restart, it started to backfill messages, except my own, although the puppet of my Google account joined (and left after backfill).

The solution was login-matrix. This allowed the puppet of my Google account to join again, backfill my own messages, and leave. However, only the messages I sent after every other person were synced because of this "Stopping backfilling at [...] as message was already bridged"-check. invite_own_puppet: true was set all the time, so these messages were sent using the puppet instead of my Matrix account, so login-matrix should not even be needed.

Full backfill config:

    backfill:
        invite_own_puppet: true
        initial_limit: 0
        missed_limit: 100
        disable_notifications: false

rooms sometimes never sync up with gchat

That's a very simplistic description, unfortunately.

What I see happening is that I will start up Element and connect it to a gchat bridge. If there has been no traffic in a given gchat channel for a while (I have not been able to quantify how long "a while" is yet -- anywhere from 24 hours to a week, so far), Element will take an extremely long time to bring the channel up to date and display any discussions at all, sometimes in the range of several hours; I have one channel where I've given up waiting for the bridge to sync up after a day or so.

It appears the bridge is just stuck. However, you can "unstick" it by posting a new thread in the gchat channel. The new thread shows up in Element and things seem to start moving again.

`@all` in Google chat does not get bridged properly

When someone on Google chat mentions everyone using @all it gets bridged as @<name of bridge bot>_:<homeserver>. This is not ideal as it doesn't give the right kind of notification to the user and should ideally be translated to @all on the matrix side.

[Feature Request] Detect formatting from Matrix client and pass through to hangups

Steps

  1. Mark some text as bold, italics, and strike through in Riot. Eg: Send the message:
    **bold** _italics_ <del>strike</del>
  2. Note these are all formatting options supported in hangouts: https://support.google.com/chat/answer/7649118?hl=en
  3. Open https://hangouts.google.com and notice the message text is not displayed as bold, italics, and strike-through but rather as the exact text **bold** _italics_ <del>strike</del>

Expected Behavior
mautrix-hangouts should parse **foo** as bold, _bar_ as italics, and <del>baz</del> as strikethrough. mautrix-hangouts should divide the message into segments and apply formatting to each segment.

Received images no longer appearing

Received images (sent by others) through hangouts are no longer appearing in Riot/Matrix clients.

Images sent through Riot/Matrix are successfully sending as expected.

Double Puppeting not working

I am trying to enable double puppeting and double puppeting does work with other bridges (mx-puppet-discord). I have set it up the Shared Secret Authenticator for synapse and I have put the shared secret into the config.yaml but when I try any of the -matrix commands such as ping-matrix the bot just replies with "This bridge has not implemented the ping-matrix command." login-matrix has the same error. Can anyone help?

setuptools not in requirements

There is currently an implicit dependency on setuptools that is not listed in requirements. This fails at runtime, as there is no pkg_resources then.

HTTP Error 429 on Manual Login

When attempting to do a manual login I get the following error after providing the token:

requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://www.google.com/sorry/index?continue=https://www.google.com/&q=REDACTED

No actual bridging happening at all

I had a problem with the bridge no longer sending/receiving any messages. I attempted to reinstall multiple times. I can see events firing in the logs when I send a message in Matrix as well as when I receive one in Hangouts, but nothing is communicated between the two services. The only error I can find is immediately after login:

[2020-09-03 04:24:03,006] [[email protected]] Authentication successful
[2020-09-03 04:24:03,673] [[email protected]] Requesting new gsessionid and SID...
[2020-09-03 04:24:03,674] [[email protected]_utils] Sending request post https://0.client-channel.google.com/client-channel/channel/bind:
{'count': 0, 'ofs': 0}
[2020-09-03 04:24:03,873] [[email protected]_utils] Received response 200 OK:
b'100\n[[0,["c","E[redacted]","",8]\n]\n,[1,[{"gsid":"h[redacted]"}]]\n]\n'
[2020-09-03 04:24:03,874] [[email protected]] New SID: E[redacted]
[2020-09-03 04:24:03,874] [[email protected]] New gsessionid: h[redacted]
[2020-09-03 04:24:03,874] [[email protected]] Opening new long-polling request
[2020-09-03 04:24:03,922] [[email protected]] Received chunk:
b'153\n[[2,[{"p":"{\\"1\\":{\\"1\\":{\\"1\\":{\\"1\\":1,\\"2\\":1}},\\"4\\":\\"[redacted]\\",\\"5\\":\\"S1\\"},\\"3\\":{\\"1\\":{\\"1\\":1},\\"2\\":\\"lcsw_hangouts_[redacted]\\"}}"}]]\n]\n'
[2020-09-03 04:24:03,922] [[email protected]] Fired Event('Channel.on_connect')
[2020-09-03 04:24:03,922] [[email protected]] Fired Event('Client.on_connect')
[2020-09-03 04:24:03,927] [[email protected]] Sending Protocol Buffer request contacts/getselfinfo:
request_header {
  client_version {
    client_id: CLIENT_ID_WEB_HANGOUTS
    major_version: "hangups-0.4.10"
  }
  language_code: "en"
}

[2020-09-03 04:24:03,927] [[email protected]_utils] Sending request post https://clients6.google.com/chat/v1/contacts/getselfinfo:
b'\n\x18\n\x12\x08,\x1a\x0ehangups-0.4.10"\x02en'
[2020-09-03 04:24:04,089] [[email protected]_utils] Received response 401 Unauthorized:
b'{\n  "error": {\n    "code": 401,\n    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",\n    "errors": [\n      {\n        "message": "Invalid Credentials",\n        "domain": "global",\n        "reason": "authError",\n        "location": "Authorization",\n        "locationType": "header"\n      }\n    ],\n    "status": "UNAUTHENTICATED"\n  }\n}\n'
[2020-09-03 04:24:04,089] [[email protected]_utils] Request returned unexpected status: 401 Unauthorized
[2020-09-03 04:24:04,090] [[email protected].@f13:[redacted]] Failed to get_self_info
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mautrix_hangouts/user.py", line 232, in on_connect_later
    info = await self.client.get_self_info(hangouts.GetSelfInfoRequest(
  File "/usr/lib/python3.8/site-packages/hangups/client.py", line 543, in get_self_info
    await self._pb_request('contacts/getselfinfo',
  File "/usr/lib/python3.8/site-packages/hangups/client.py", line 413, in _pb_request
    res = await self._base_request(
  File "/usr/lib/python3.8/site-packages/hangups/client.py", line 469, in _base_request
    res = await self._session.fetch(
  File "/usr/lib/python3.8/site-packages/hangups/http_utils.py", line 86, in fetch
    raise exceptions.NetworkError(
hangups.exceptions.NetworkError: Request return unexpected status: 401: Unauthorized

After this error I continue to see regular log updates, including what appear to be Hangouts events, including:

[2020-09-03 04:35:10,004] [[email protected]] Received StateUpdate:
state_update_header {
  active_client_state: ACTIVE_CLIENT_STATE_OTHER_ACTIVE
  request_trace_id: "-[redacted]"
  notification_settings {
    dnd_settings {
      do_not_disturb: false
    }
  }
  current_server_time: [redacted]
}
event_notification {
  event {
    conversation_id {
      id: "[redacted]"
    }
    sender_id {
      gaia_id: "[redacted]"
      chat_id: "[redacted]"
    }
    timestamp: [redacted]
    self_event_state {
      user_id {
        gaia_id: "[redacted]"
        chat_id: "[redacted]"
      }
      client_generated_id: "[redacted]"
      notification_level: NOTIFICATION_LEVEL_RING
    }
    chat_message {
      message_content {
        segment {
          type: SEGMENT_TYPE_TEXT
          text: "asdf"
          formatting {
            bold: false
            italic: false
            strikethrough: false
            underline: false
          }
        }
      }
    }

and others.

I have tried completely removing the mautrix database and restarting the docker container from scratch and I still get the same result. Aside from the one error noted above, the log makes no indication whatsoever that anything is amiss.

Any thoughts?

"Can't update() without base config" if installed via setup.py

If I follow the wiki instructions and use a virtual env, then everything works if I launch like this:

$ python -m mautrix_hangouts -c /etc/synapse/mautrix-hangouts/config.yaml -r /etc/synapse/mautrix-hangouts/registration.yaml

But if I install locally with setup.py, then running mautrix-hangouts complains if I don't give the -b option.

$ mautrix-hangouts -c /etc/synapse/mautrix-hangouts/config.yaml -r /etc/synapse/mautrix-hangouts/registration.yaml                                          Traceback (most recent call last):                                                                                                                                                            
  File "/usr/bin/mautrix-hangouts", line 11, in <module>                                                                                                                                      
    load_entry_point('mautrix-hangouts==0.1.0.dev7+dev.1241db9b', 'console_scripts', 'mautrix-hangouts')()                                                                                      File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point                                                                                            
    return get_distribution(dist).load_entry_point(group, name)                                                                                                                               
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point                                                                                           
    return ep.load()                                                                                                                                                                            File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load                                                                                                       
    return self.resolve()                                                                                                                                                                     
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve                                                                                                        module = __import__(self.module_name, fromlist=['__name__'], level=0)                                                                                                                       File "/usr/lib/python3.8/site-packages/mautrix_hangouts/__main__.py", line 78, in <module>                                                                                                      HangoutsBridge().run()                                                                                                                                                                      File "/usr/lib/python3.8/site-packages/mautrix/bridge/bridge.py", line 83, in run                                                                                                           
    self._prepare()                                                                                                                                                                             File "/usr/lib/python3.8/site-packages/mautrix/bridge/bridge.py", line 105, in _prepare                                                                                                         self.prepare_config(self.args.config, self.args.registration, self.args.base_config)                                                                                                      
  File "/usr/lib/python3.8/site-packages/mautrix/bridge/bridge.py", line 128, in prepare_config                                                                                                   self.config.update()                                                                                                                                                                      
  File "/usr/lib/python3.8/site-packages/mautrix/util/config.py", line 151, in update                                                                                                         
    raise ValueError("Can't update() without base config")                                                                                                                                    
ValueError: Can't update() without base config

Works fine if I provide -b and point at the example config:

$ mautrix-hangouts -c /etc/synapse/mautrix-hangouts/config.yaml -r /etc/synapse/mautrix-hangouts/registration.yaml -b /usr/example-config.yaml

bridge fails to start after restart

[2020-04-27 16:00:15,361] [[email protected]] Starting appservice web server on 0.0.0.0:29320
[2020-04-27 16:00:15,363] [[email protected]] Ensuring connectivity to homeserver
[2020-04-27 16:00:15,363] [[email protected]] GET /_matrix/client/r0/account/whoami {}
[2020-04-27 16:00:16,449] [[email protected].@anthony:nova.chat] GET /_matrix/client/r0/account/whoami {}
[2020-04-27 16:00:16,467] [[email protected]] Initializing appservice bot
[2020-04-27 16:00:16,488] [[email protected]] PUT /_matrix/client/r0/profile/%40_anthony_hangouts_bot%3Anova.chat/displayname {"displayname": "Hangouts bridge bot"}
[2020-04-27 16:00:16,604] [[email protected]] Initialized custom mxid: @anthony:nova.chat. Not starting sync task
[2020-04-27 16:00:17,015] [[email protected]] PUT /_matrix/client/r0/profile/%40_anthony_hangouts_bot%3Anova.chat/avatar_url {"avatar_url": "mxc://maunium.net/FBXZnpfORkBEruORbikmleAy"}
[2020-04-27 16:00:17,383] [[email protected]] Logging in with bridge bot user
[2020-04-27 16:00:17,486] [[email protected].@anthony:nova.chat] Failed to resume session with stored refresh token
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/hangups/auth.py", line 427, in _get_session_cookies
    r.raise_for_status()
  File "/usr/lib/python3.8/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://www.google.com/sorry/index?continue=https://www.google.com/&q=EhAqAQeDS-gRPQ2xlIaesyhd-NS7tMgFy

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/mautrix-hangouts/mautrix_hangouts/util/hangups_try_auth.py", line 30, in try_auth
    return TryAuthResp(success=True, cookies=_get_session_cookies(session, access_token),
  File "/usr/lib/python3.8/site-packages/hangups/auth.py", line 429, in _get_session_cookies
    raise GoogleAuthError('MergeSession request failed: {}'.format(e))
hangups.auth.GoogleAuthError: MergeSession request failed: 429 Client Error: Too Many Requests for url: https://www.google.com/sorry/index?continue=https://www.google.com/&q=EhAqAesyhd-NS7tMgFy
[2020-04-27 16:00:17,826] [[email protected]] Loading room and member list into encryption client

Unnecessary dependency on setuptools

setup.py includes setuptools in its install_requires (via requirements.txt).

As far as I can tell, setuptools is not used after installation, so this should be put in setup_requires or just removed.

Room and user name should fall back to mail

Hello there!

I started a hangouts chat with someone, whom I never sent an email earlier. This way hangouts started the chat with a contact and somehow didn't find their name. In the hangouts app (in webbrowser) it falls back to the email address, yet in matrix I see Unknown. Which is not very informative. :) Is it possible to check for the Unknown string and fall back in such cases? Or maybe there is an easier solution?

Thank you in advance
Gergely

Support for community groups?

Hello. I'm not sure if community groups are supported or not in this project - can anybody shed any light on this? I'm referring to essentially the community_template option in example-config.yaml. I have set it but I don't see any obvious effects, nor any documentation that refers to this option.

Are there additional steps, or is this currently unsupported?

Don't log private information by default

Logs currently contain message content and other private information. The logs should be minimized to contain as little private information as possible without reducing usefulness when debugging.

Problems during initial backfill

The following issue is a summary of my "Wall of text"-like messages in the support room.

I recreated the bridge and do a login. Automatic login had some issue, I falled back to manual login, which was successful. After that in Riot a single room was created, corresponding to my latest contact, my user invited and no message was backfilled. Initial backfill was enabled, 5 room and 75 messages each, should've been backfilled.

In bridge log I saw that connection was indeed successful, all my contacts were recognized, the configuration file should be good, as the log says Server returned 5 conversations as it should, than starts backfilling the first user (the latest), with the following query:

Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: request_header {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   client_version {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     client_id: CLIENT_ID_WEB_HANGOUTS
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     major_version: "hangups-0.4.10"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   client_identifier {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     resource: "lcsw_hangouts_OBFUSCATE-ID"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   language_code: "en"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: conversation_spec {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   conversation_id {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     id: "OBFUSCATE-ID"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: include_conversation_metadata: false
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: include_event: true
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: max_events_per_conversation: 75

after that a really long response arrives, with the 75 messages. It also seems good. After that the following query is sent:

Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: [2020-06-29 09:31:18,819] [[email protected]] Sending Protocol Buffer request conversations/getconversation:
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: request_header {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   client_version {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     client_id: CLIENT_ID_WEB_HANGOUTS
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     major_version: "hangups-0.4.10"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   client_identifier {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     resource: "lcsw_hangouts_ID"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   language_code: "en"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: conversation_spec {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   conversation_id {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:     id: "ID"
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: include_conversation_metadata: false
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: include_event: true
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: max_events_per_conversation: 0
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: event_continuation_token {
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   storage_continuation_token: " TOKEN
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]:   event_timestamp: 1589825871012680
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: }
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: [2020-06-29 09:31:18,822] [[email protected]_utils] Sending request post https://clients6.google.com/chat/v1/conversations/getconversation:
Jun 29 11:31:18 raspberrypi matrix-mautrix-hangouts[18773]: b'LONGSTRING
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: [2020-06-29 09:31:19,050] [[email protected]_utils] Received response 200 OK:
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: b'LONGSTRING'

and the server response is

Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: [2020-06-29 09:31:19,052] [[email protected]] Received Protocol Buffer response:
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: response_header {
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]:   status: RESPONSE_STATUS_OK
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]:   current_server_time: 1593423078910000
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: }
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: conversation_state {
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]:   conversation_id {
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]:     id: "ID"
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]:   }
Jun 29 11:31:19 raspberrypi matrix-mautrix-hangouts[18773]: }

This query-response is happening for about 3 hours now, in an infinte loop, and nothing in Riot appeared.

My idea was, that somehow the bridge sees that 75 messages out of the querried 75 is already arrived, and tries to querry the last 0 messages, but it does not give the expected results so keeps on trying. My idea is based on the fact that in the infinte query there is an event_continuation_token.

To check it I also tried it first with a 100 messages, than with 50 messages. Neither helped. I tried restarting the bridge with and without leaving that particular room. Nothing helped.

Any idea what my go wrong?

Causes tons and tons of errors in Synapse log

I use both this and mautrix-facebook, and both cause this behavior. I get multiple of these each second in my Synapse logs:

Apr 12 18:50:13 matrix matrix-synapse[18641]: 2020-04-12 23:50:13,529 - synapse.http.server - 110 - ERROR - GET-129521 - Failed handle request via 'SyncRestServlet': <XForwardedForRequest at 0x7f182d5e6bd0 method='GET' uri='/_matrix/client/r0/sync?access_token=<redacted>&timeout=30000&filter=%7B%22presence%22:%7B%22not_types%22:%5B%22*%22%5D%7D,%22account_data%22:%7B%22types%22:%5B%22*%22%5D%7D,%22room%22:%7B%22ephemeral%22:%7B%22not_types%22:%5B%22*%22%5D,%22lazy_load_members%22:false,%22include_redundant_members%22:false%7D,%22include_leave%22:false,%22state%22:%7B%22not_types%22:%5B%22*%22%5D,%22lazy_load_members%22:false,%22include_redundant_members%22:false%7D,%22timeline%22:%7B%22not_types%22:%5B%22*%22%5D,%22lazy_load_members%22:false,%22include_redundant_members%22:false%7D,%22account_data%22:%7B%22not_types%22:%5B%22*%22%5D,%22lazy_load_members%22:false,%22include_redundant_members%22:false%7D%7D%7D' clientproto='HTTP/1.1' site=8008>
Apr 12 18:50:13 matrix matrix-synapse[18641]: Traceback (most recent call last):
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/http/server.py", line 78, in wrapped_request_handler
Apr 12 18:50:13 matrix matrix-synapse[18641]: await h(self, request)
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/http/server.py", line 331, in _async_render
Apr 12 18:50:13 matrix matrix-synapse[18641]: callback_return = await callback_return
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/rest/client/v2_alpha/sync.py", line 178, in on_GET
Apr 12 18:50:13 matrix matrix-synapse[18641]: full_state=full_state,
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/handlers/sync.py", line 286, in wait_for_sync_for_user
Apr 12 18:50:13 matrix matrix-synapse[18641]: full_state,
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Apr 12 18:50:13 matrix matrix-synapse[18641]: result = g.send(result)
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/handlers/sync.py", line 312, in _wait_for_sync_for_user
Apr 12 18:50:13 matrix matrix-synapse[18641]: sync_config, since_token, full_state=full_state
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/handlers/sync.py", line 343, in current_sync_for_user
Apr 12 18:50:13 matrix matrix-synapse[18641]: return await self.generate_sync_result(sync_config, since_token, full_state)
Apr 12 18:50:13 matrix matrix-synapse[18641]: File "/usr/local/lib/python3.7/site-packages/synapse/handlers/sync.py", line 982, in generate_sync_result
Apr 12 18:50:13 matrix matrix-synapse[18641]: raise NotImplementedError()
Apr 12 18:50:13 matrix matrix-synapse[18641]: NotImplementedError

When I shut down the Facebook and Hangouts bridges, these go away. Start them up again, and they return.

A comment in the Synapse code that appears to be relevant directs to matrix-org/matrix-spec-proposals#1144

networkerror, fixed with a restart

can the bridge detect these kinds of things and automatically reboot itself? It was fixed by a docker restart

[2020-02-25 08:14:03,486] [[email protected]] Received new client_id: 'lcsw_hangouts_1D822926'
[2020-02-25 08:14:03,487] [[email protected]] Adding channel services...
[2020-02-25 08:14:03,894] [[email protected]] Channel services added
[2020-02-25 08:14:59,713] [[email protected]] Opening new long-polling request
[2020-02-25 08:18:35,414] [[email protected]] Opening new long-polling request
[2020-02-25 08:22:40,654] [[email protected]] Opening new long-polling request
[2020-02-25 08:24:08,389] [[email protected]] Long-polling interrupted: SID is about to expire
[2020-02-25 08:24:08,391] [[email protected]] retry attempt count is now 1
[2020-02-25 08:24:08,392] [[email protected]] Backing off for 2 seconds
[2020-02-25 08:24:10,395] [[email protected]] Requesting new gsessionid and SID...
[2020-02-25 08:24:10,625] [[email protected]_utils] Request returned unexpected status: 404 Not Found
[2020-02-25 08:24:10,626] [[email protected].@eric:eric.nova.chat] Exception in connection
Traceback (most recent call last):
  File "/opt/mautrix-hangouts/mautrix_hangouts/user.py", line 163, in start
    await self.client.connect()
  File "/usr/lib/python3.7/site-packages/hangups/client.py", line 138, in connect
    await self._listen_future
  File "/usr/lib/python3.7/site-packages/hangups/channel.py", line 188, in listen
    await self._fetch_channel_sid()
  File "/usr/lib/python3.7/site-packages/hangups/channel.py", line 257, in _fetch_channel_sid
    res = await self.send_maps([])
  File "/usr/lib/python3.7/site-packages/hangups/channel.py", line 233, in send_maps
    'post', CHANNEL_URL, params=params, data=data_dict
  File "/usr/lib/python3.7/site-packages/hangups/http_utils.py", line 88, in fetch
    .format(res.status, res.reason)
hangups.exceptions.NetworkError: Request return unexpected status: 404: Not Found

Quoting text is broken

Replying to a previous message results in a quote of that message appearing in the senders chat window. However, the receiver just sees the sender's new message, without the context provided by the quoted message. This leads to significant misunderstandings in Google chat conversations.

Could the bridge be modified to prepend the senders message with the quote for context? e.g. the receiver might see:

BOB SAID: "this was bob's message"
This is senders reply.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.