1
0
Fork 0
Commit Graph

90 Commits

Author SHA1 Message Date
nicoco 6c44ea555d fix: logout command 2024-04-30 20:31:11 +02:00
Alex Palaistras 1275ef55d1 Don't update presence status if not needed
Status messages are sent with every presence update by some XMPP
clients, which would previously result in corresponding changes being
made on the WhatsApp side, where no effective change in status has been
made since.

This commit implements naive caching for presence status in order to
avoid most double-sets, but which however will clear across restarts.
2024-04-30 18:21:52 +01:00
Alex Palaistras f2b4997473 Update Go dependencies 2024-04-29 21:21:17 +01:00
Alex Palaistras e0c7c5c13d Ignore Broadcast and Status messages
Status messages and Broadcasts require special handling on the Slidge
side, especially where read receipts are concerned. However, if not
handled specifically, these will currently default to being handled
as (strange) group-chats, which might be responsible for crashes etc.

This commit has these message types be explicitly unhandled until we
introduce support for handling these properly.
2024-04-18 11:37:24 +01:00
nicoco 72ebb936d2 fix: mention of unknown contacts from whatsapp
It may happen that a participant who hasn't shared
their "push name" with us is mentioned in a chat by
another participant.
Before this fix, this would result in replacing the mention
with an empty string.
2024-03-25 09:00:35 +01:00
nicoco 14a584e9a6 fix: allow moderators to modify room config
...by making them "XMPP owners"
2024-03-24 14:03:19 +01:00
Alex Palaistras 1f6c7ac4ab Update dependencies 2024-03-23 11:40:20 +00:00
nicoco c4af612543 fix: do not set subject in rooms without description
Setting the subject in rooms that don't have one
resulted in an empty subject with a timestamp of
'0001-01-01T00:00:00Z', which in turned raise warnings
in gajim's logs.

This commit changes the behaviour setting a subject
and a subject date only if they are given by WA's
servers.
2024-03-02 06:28:35 +01:00
nicoco d32f1f0a9e fix: check that oldest_message_id is not None in MUC.backfill()
does not seem to trigger any issue but mypy does not like it

also, paint it newer black
2024-03-02 06:28:35 +01:00
Alex Palaistras 59957fd436 Update to latest versions of dependencies 2024-02-26 18:10:33 +00:00
Alex Palaistras 9caf826b0b Implement history sync on first login
This commit implements history synchronization/back-fill on first login,
as allowed by WhatsApp. Currently, only history for group-chats/MUCs is
allowed, as 1:1 history synchronization is not operational without core
changes/support/privileges for the user's MAM.

In addition, even though on-demand backfills have been implemented, they
are considered to be inert/of limited use until persistent message
storage is implemented, as the `session.muc_sent_msg_ids` storage
currently utilized is in-memory only, and WhatsApp requires full message
metadata for on-demand history synchronization.
2024-02-23 17:09:33 +00:00
nicoco e3c36becdc feat: group creation and affiliation changes 2024-02-17 14:51:10 +01:00
nicoco c745aa4050 chore: update entrypoint 2024-02-17 14:49:38 +01:00
nicoco 34f1c0c47d feat: add emojis in adhoc command names
Arguably, it looks a bit better in XMPP clients this way
2024-02-17 09:32:18 +01:00
nicoco 8879489b80 fix: whatsapp message retractions in direct chats 2024-02-17 09:30:56 +01:00
nicoco af1149313b chore: update go dependencies 2024-02-17 09:30:56 +01:00
nicoco 6727da086a feat: bridge XMPP mentions as proper whatsapp mentions
This has outgoing mentions of participant usernames in MUCs be correctly
represented as mentions in official WhatsApp clients.
2024-02-17 08:44:03 +01:00
Alex Palaistras c40c9747e4 Bump voice message bit-rate to 64k
This helps improve quality, and appears to be well-supported by official
WhatsApp clients. In addition, a bug concerning the handling of ALAC
files has been fixed (which would previously not send through correctly,
owing to WhatsApp's lack of handling for these).
2024-02-16 22:11:59 +00:00
nicoco 7b87bfe29a feat: moderate messages from WhatsApp
Implements: https://todo.sr.ht/~nicoco/slidge-whatsapp/19
2024-02-11 07:01:44 +01:00
nicoco 0bf051a7d6 feat: moderate messages from XMPP
Includes a fix for the role of admin and
owner to "moderator", or else gajim wouldn't
display the option to actually moderate a
message.

Implements: https://todo.sr.ht/~nicoco/slidge-whatsapp/21
2024-02-11 07:01:44 +01:00
nicoco 69a4e27395 feat: set group name and topic
Implements: https://todo.sr.ht/~nicoco/slidge-whatsapp/24
2024-02-11 07:01:44 +01:00
nicoco 6440e97331 style: paint it newer black 2024-02-11 07:01:44 +01:00
Alex Palaistras f5f845043a Fix help text for `subscribe` command 2024-02-10 17:58:29 +00:00
Alex Palaistras ba1cbbafe3 Re-implement `subscribe` command
This allows for re-subscribing to contact presences without returning
the large response for the `contacts` command.
2024-02-10 17:53:57 +00:00
nicoco 7f12bb4179 feat: set group avatar 2024-01-22 09:29:16 +01:00
nicoco 662d7c63fe fix: signature of on_correct() and on_text() 2024-01-19 22:06:56 +01:00
nicoco 2c92f06d68 fix: adjust signature of BaseSession.on_correct() 2024-01-17 09:33:12 +01:00
Alex Palaistras 677fffa0c2 attachment: Fix incorrect use of detected MIME 2024-01-10 23:56:14 +00:00
Alex Palaistras fe82c63b1e Use detected MIME type in attachment conversion
Previously, we would rely on the client-reported MIME type, unless this
was empty or invalid, in making the determination of whether we
should (or not) convert a given attachment to a better-supported format.
However, client support for MIME type reporting is sporadic,
error-prone, and known-to-be-buggy in some cases (e.g. Conversations
reporting MP4 voice recordings as `audio/mpeg`).

This commit moves to using auto-detected MIME types for attachment
conversions, and adds some additional matching for known edge-cases.
In general, attachments will now have their MIME type, as presented to
WhatsApp, changed *only* if conversion takes place; the only exception
is when an empty or invalid MIME type was self-reported.
2024-01-07 19:48:29 +00:00
Alex Palaistras 3713cfe7ad Allow for disconnecting from WhatsApp with command
This commit introduces a new ad-hoc command, `logout`, which disconnects
from WhatsApp without unlinking our authentication credentials (i.e.
what is generally understood to be meant when saying "log out").
2024-01-07 16:13:42 +00:00
Alex Palaistras 3ca6948639 Update to latest Slidge core version
This also renames `Session` event handlers for corresponding changes in
core, and cleans up some "private" methods for better consistency.
2024-01-07 16:09:32 +00:00
Alex Palaistras f4ecbee5d2 Implement search by phone number
Searching by phone number will check for a contact on WhatsApp, and if
existing, automatically add that contact to the roster. However, contact
names are not resolved until after they've been added to the roster and
been communicated with.
2023-12-18 14:02:51 +01:00
Alex Palaistras 7eedd28d28 Update to latest GoPy version, fix issues
This fixes issues related to breaking changes in latest versions of
GoPy, which will now return concrete instances of corresponding classes
in iterators; previously, only a "pointer" would be returned, which
would've then needed to be set as the handle for a newly created
instance of a relevant class.

Closes: #17
2023-12-14 18:57:27 +00:00
Alex Palaistras 61db123ace Update dependencies, implement stub validation
Stub validation for our `Gateway` class is required in completing
registration, even though we don't process any forms.
2023-12-12 17:25:19 +00:00
nicoco 64f23f03e2 fix: group avatar unset 2023-12-11 22:35:36 +01:00
nicoco 82c3e6cb5b fix: update avatar before joining 2023-12-11 22:34:58 +01:00
nicoco e881e89616 fix: git merge gone wrong 2023-12-05 14:15:46 +01:00
nicoco 0b98cfff46 style: apply isort and black 2023-12-05 14:02:48 +01:00
nicoco 2644448177 fix: workaround for type-hint limitation
path should never be None when
NO_UPLOAD_METHOD != "symlink",
but the type annotation is suboptimal
2023-12-05 14:02:34 +01:00
nicoco befb1920dc feat: sync user avatar unpublishing 2023-12-05 13:34:26 +01:00
nicoco c3d27da861 feat: sync user avatar unpublishing 2023-12-05 12:18:03 +01:00
Alex Palaistras 10e1b93ed1 Remove debug-only logging for `SetAvatar` 2023-12-01 13:40:52 +00:00
Alex Palaistras 54c30a4abc Cache group avatars for unique WhatsApp ID
This follows the same paradigm used for contacts, and uses the
unique (and stable) WhatsApp-provided avatar ID as a cache key.
2023-12-01 13:35:10 +00:00
Alex Palaistras a42f4c311b Handle XMPP-to-WhatsApp avatar synchronization
Setting your avatar in XMPP will now propagate to WhatsApp, but not the
other way around; even so, most XMPP clients will update the avatar anew
on new connections, which should help ensure persistent synchronization
even in the face of remote changes to the WhatsApp profile.
2023-12-01 13:32:05 +00:00
Alex Palaistras 7671411883 Update dependencies to latest versions 2023-12-01 13:31:57 +00:00
Alex Palaistras 9be035d6a2 Update dependencies to latest versions 2023-11-14 17:33:26 +00:00
Alex Palaistras 42f9551b00 Rename `media.go` to `attachment.go`
Since the latter name is more appropriate for its contents.
2023-09-30 12:34:10 +01:00
Alex Palaistras df950e0bb3 Use local, temporary files for attachments
Incoming and outgoing attachments (and preview images) will typically be
transported between the Python-Go boundary as raw, in-memory byte
representations; however, this has been the source of issues in the
past, since our Go-Python glue layer does not handle translating byte
slices in a performant enough way.

Thus, we have relied on transporting attachments as URLs, local paths,
and raw byte slices interchangeably, using whichever method has been
more appropriate for the use-case. Similarly, we have typically used
in-memory byte slices and pipes for our media conversion layer between
Go and FFmpeg, in order to avoid spurious writes to disk.

Unfortunately, FFmpeg does not handle conversion of media files using
pipes in all cases, and more specifically, in the case of MP4 container
formats, which usually require the entire buffer to be available and
cannot handle conversions from streamed sources (such as pipes).

This commit consolidates use of local, temporary file paths for the
purposes of both attachment and media conversion handling, which (may)
simplify the implementation, but may also lead to increased latency, as
files need to be read from and written to when crossing Go-Python and
FFmpeg boundaries.

Future improvements to GoPy and our FFmpeg implementation might have us
revisit and revert back to raw byte slices.
2023-09-30 12:34:07 +01:00
nicoco 5fc53ab796 chore: update slidge 2023-09-24 14:55:31 +02:00
Alex Palaistras d01c37af51 Implement phone pairing with `pair-phone` command
WhatsApp allows secondary, "linked" devices to pair with the main device
via either QR code, or more recently, via one-time code. Both methods
are equivalent in their outcomes, but one-time code pairing might be
easier to use for users that use the same device for both WhatsApp and
XMPP, as scanning a QR code temporarily requires a second device (or
printer). Conversely, one-time codes can be received and used by the
same device.

This commit implements this form of one-time code pairing via a new
`pair-phone` command, to be used as a ad-hoc command against the
Slidge component; this form of pairing requires entering the phone
number used by the main device, and returns a small one-time code that
can be used in the "Link Device" dialog on the main device.

This does not, and will not, replace QR code pairing -- both methods
will continue to be available on Slidge so long as they're available
upstream.
2023-09-17 11:28:39 +01:00