Commit Graph

348 Commits

Author SHA1 Message Date
Toni Spets 8ac519d1e5 connector: Disconnect in a goroutine on auth error
If we get bad creds on initial connect the lock is being held when the
callback is called.
2025-06-25 08:55:36 +03:00
Tulir Asokan a49818b863 dependencies: update mautrix-go 2025-06-17 20:35:16 +03:00
Toni Spets fa237a20f7 logging: Move gotd debug logs to trace
Zap doesn't have trace level logging so to make it less noisy we need to
shift them to trace.
2025-06-09 15:01:25 +03:00
Toni Spets e7b87835b6 Fix a race between connect and disconnect
If we get an auth error during connect we did deadlock.
2025-06-06 10:57:07 +03:00
Toni Spets 3c3c3f1dec client: Prefer contact name if exists
Don't allow TG user to override your own contact name for them after
they have been made a contact.
2025-05-30 13:22:57 +03:00
Toni Spets a9a267bc0d directmedia: handle webpage previews as well 2025-05-27 14:39:47 +03:00
Tulir Asokan 05b1eb1214 handletelegram: provide stream order in read receipts (#102) 2025-05-27 11:45:39 +03:00
Toni Spets 0f36833e89 Revert "Revert "client: unblock connect without network""
This reverts commit ea4626107c.

Adds waiting support for initial connection established to avoid locking
up gotd. This isn't extremely pretty but should do the job for now.
2025-05-27 07:40:38 +03:00
Toni Spets ea4626107c Revert "client: unblock connect without network"
This reverts commit 14c784f2a2.
2025-05-23 10:32:51 +03:00
Toni Spets 39c1b685d6 client: logout with timeout to API call to unblock it 2025-05-23 09:28:32 +03:00
Toni Spets 14c784f2a2 client: unblock connect without network
It'll still probably not race too much if disconnect gets called while
connecting is still stuck doing something.
2025-05-23 09:20:38 +03:00
Toni Spets 11f105c0e7 media: convert png and jpeg stickers to webp without ffmpeg 2025-05-22 13:52:51 +03:00
Toni Spets 9e719429e7 Fix handle channel photo edits as well as group chats 2025-05-21 08:15:23 +03:00
Tulir Asokan d2bb02b259 handlematrix: use client-generated transaction IDs 2025-05-09 16:42:44 +03:00
Toni Spets 7e75c8ef83 media: make all media direct downloadable
The only exception is emojis.

Also changed direct download encoding field names to be more generic
when used in mixed manner depending on peer type.

Direct downloads are still somewhat inefficient as they require an API
round trip to succeed but we can cache things in the database if needed.
2025-05-07 06:43:51 +03:00
Brad Murray 9d3e9df57e Merge pull request #98 from mautrix/dont-500-on-resolve-identifier-not-resolving
Use 404 status when not matching a valid identifier
2025-05-06 13:16:13 -04:00
Toni Spets 483816cc2b media: Request 1MB chunks for direct media streaming
The default is 512kB and the RPC request overhead has more impact
on download speed than having half smaller chunks.

Next level speed improvement would be to use parallel downloads and
have an on-disk buffer to stream out the rebuilt file on-the-fly when
we consistent stream of data available.
2025-04-28 12:38:02 +03:00
Toni Spets 7c13481ede client: Handle connect/disconnect/auth races properly
When logging out, we should first handle network level logout and after
that ensure the client is disconnected before removing state to avoid
having event handling during disconnect from touching anything anymore.

I don't know why we nilled the client but since so many places use it
we'd rather get errors rather than panics if it's being used after
logging out but previous lifecycle fixes should avoid that.
2025-04-26 08:19:33 +03:00
Adam Van Ymeren eb5ae65402 reactions: fix db race when handling reactions on newly received old messages (#100) 2025-04-25 13:19:50 -07:00
Toni Spets 53e89441b7 media: fix lottie mime type for direct download 2025-04-25 07:38:06 +03:00
Tulir Asokan 48d91fdf76 media/sticker: fix lottie mime type
It's always gunzipped, so should never send the application/x-tgsticker mime.
Also, video/lottie+json was recently registered with IANA, so use that instead
of the old image/lottie+json: <https://www.iana.org/assignments/media-types/video/lottie+json>
2025-04-24 15:56:44 +03:00
Brad Murray bdae6dd620 Use 404 status when not matching a valid identifier 2025-04-17 13:10:34 -04:00
Toni Spets 224b01e7a4 client: Wait for updates manager to finish on disconnect 2025-04-15 12:19:28 +03:00
Tulir Asokan 5421de8e76 handlematrix: include stream order in response 2025-04-11 23:01:06 +03:00
Toni Spets a64a178dc3 client: Don't try to reconnect with canceled context 2025-04-10 10:13:02 +03:00
Toni Spets 538f2a2ec0 client: Wait before returning from disconnect 2025-04-09 10:49:45 +03:00
Nick Mills-Barrett 10b8c4b635 chatinfo: log when chats have no or unknown photo types 2025-04-07 13:58:53 +01:00
Sumner Evans b955252a6a backfill: add stream order
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-03-28 08:33:33 -06:00
Tulir Asokan 6347383788 tomatrix: fix refetching channel media when bridging messages 2025-03-27 18:31:48 +02:00
Tulir Asokan 28d8276554 dependencies: update mautrix-go 2025-03-25 17:00:55 +02:00
Sumner Evans 09b1e69c0f backfill: fix NPE if no messages found
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-03-13 11:58:18 -06:00
Sumner Evans 854f66cb04 store: make finding by username case-insensitive
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-03-05 18:17:30 -07:00
Sumner Evans 1bc3a2538e treewide: add copyright/license notices
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-03-05 10:16:50 -07:00
Sumner Evans dcc8689835 emojis: properly handle inline emojis on local
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-03-04 11:27:09 -07:00
Sumner Evans ebc1aa05b1 connector/login: fix a context issue on phone number login
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-02-26 11:22:48 -07:00
Sumner Evans a56f2977b4 login: fix contexts
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-02-25 08:35:31 -07:00
Sumner Evans 36bb741c68 client: refetch message during conversion if file reference expired
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-02-24 11:45:21 -07:00
Sumner Evans e8ee5f174e connector/tomatrix: include previewed URL in hash
This will hopefully make it so that if the preview gets edited in by
Telegram at a later time, it will be bridged.

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-02-17 14:14:15 -07:00
Sumner Evans 0712ca5d0c dependencies: update go
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-02-17 14:13:12 -07:00
Sumner Evans dad34f9a3c connector: fix getting media filename fallback
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-02-17 13:53:16 -07:00
Tulir Asokan c2e07d5e3f push: add APNs push parsing 2025-02-06 15:13:31 +02:00
Tulir Asokan 255c1e2e57 push: fix types 2025-02-04 19:14:57 +02:00
Tulir Asokan a680036177 push: fix parsing decrypted json 2025-02-04 18:08:23 +02:00
Tulir Asokan 94789daed3 capabilities: fix image mime types 2025-02-04 18:06:25 +02:00
Tulir Asokan ab9ff87815 push: log data if it's not json 2025-02-04 15:46:58 +02:00
Tulir Asokan 4b08ab6ac0 push: implement ConnectBackground (#88)
* push: implement ConnectBackground

* push: disable background resync by default
2025-01-29 15:35:54 +02:00
Tulir Asokan 823eda7589 push: implement parsing native notifications (#87) 2025-01-24 15:34:34 +02:00
Tulir Asokan b158ba6b8b capabilities: add default emoji list hash to ID
The list can change, so it should change the ID too
2025-01-14 14:57:58 +02:00
Tulir Asokan 571152cb41 capabilities: update reaction settings 2025-01-14 14:56:22 +02:00
Sumner Evans c82b273155 connector/reactions: return error if not logged in
Previously, the getAvailableReactions function was only called with a
logged in client. However, now that it is called in the GetCapabilities
call, the client is no longer guaranteed to be logged in.

This was causing an NPE due to the (*TelegramClient).client being nil.

This commit makes the getAvailableReactions function not panic when the
client is not logged in.

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
2025-01-13 21:28:26 -07:00