Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send group messages via dbus-send? #272

Closed
hasdf opened this issue Mar 5, 2020 · 5 comments
Closed

How to send group messages via dbus-send? #272

hasdf opened this issue Mar 5, 2020 · 5 comments
Labels

Comments

@hasdf
Copy link

hasdf commented Mar 5, 2020

Can somebody explain how to send group messages via dbus-send?

This works great for sending to a single recipient:

dbus-send --session --type=method_call --print-reply --dest="org.asamk.Signal" /org/asamk/Signal org.asamk.Signal.sendMessage string:MessageText array:string: string:RECIPIENT

I found void sendGroupMessage in Signal.java, but I'm not sure how to pass that group ID to dbus-send.

Thank you!

@hasdf hasdf changed the title Group messages via dbus-send possible? How to send group messages via dbus-send? Mar 5, 2020
@exquo
Copy link
Contributor

exquo commented Mar 21, 2020

Sending to a group can be done with a similar command:

dbus-send --session --type=method_call  --print-reply --dest=org.asamk.Signal /org/asamk/Signal org.asamk.Signal.sendGroupMessage  string:'The message goes here'  array:string:'/path/to/attachmnt1','/path/to/attachmnt2'  array:byte:139,22,72,247,116,32,170,104,205,164,207,21,248,77,185

where the byte array at the end is the groupId in the bytes form. It can be obtained from the list of groupIds:

dbus-send --session --type=method_call  --print-reply --dest='org.asamk.Signal' /org/asamk/Signal org.asamk.Signal.getGroupIds

Note: when daemon was started without explicit -u USERNAME, all the dbus-send commands require adding the phone number in /org/asamk/Signal/_<phonenum>. See signal-cli-dbus man page.

To get the group name corresponding to a groupId, run

dbus-send --session --type=method_call  --print-reply --dest='org.asamk.Signal' /org/asamk/Signal org.asamk.Signal.getGroupName    array:byte:139,22,72,247,116,32,170,104,205,164,207,21,248,77,185     

Alternatively, the groupId byte array can be obtained from the base64-encoded groupId that looks like ixZI93QgqmjNpM8V+E25== and can be found in signal-cli's config file, by default in ~/.local/share/signal-cli/data/<PHONE_NUMBER>. To decode it to byte array, can use python:

python3 -c 'import base64; print(",".join(str(i) for i in base64.b64decode(b"ixZI93QgqmjNpM8V+E25==")))'

@AsamK AsamK added the support label Mar 21, 2020
@exquo
Copy link
Contributor

exquo commented Mar 21, 2020

One dbus quirk here: it takes bytearrays as input (for sendGroupMessage and getGroupName) in the form 139,22,72,247,.., but returns bytearrays (by getGroupIds) as space-separated hex digits 8b 16 48 f7 74 20 aa 68 cd a4 cf 15 f8 4d b9. To convert one to the other:

python3 -c 'print(",".join(str(x) for x in bytes.fromhex("8b 16 48 f7 74 20 aa 68 cd a4 cf 15 f8 4d b9")))'

@hasdf
Copy link
Author

hasdf commented Mar 21, 2020

Thank you for the detailed explanation!

Stay healthy :)

@patcon
Copy link

patcon commented Apr 25, 2021

Note that /org/asamk/Signal is now /org/asamk/Signal/_15555555555 (where 15555555555 is your phone number on account)

If you don't do this, you will get error:

Error org.freedesktop.dbus.errors.UnknownObject: /org/asamk/Signal is not an object provided by this process.

@exquo
Copy link
Contributor

exquo commented Apr 25, 2021

Thanks for the comment! I've added a note to my post above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants