bbernhard / signal-cli-rest-api

Dockerized Signal Messenger REST API
https://bbernhard.github.io/signal-cli-rest-api/
MIT License
1.17k stars 143 forks source link

Using UUID with Signal CLI REST API #550

Open tzindler opened 1 week ago

tzindler commented 1 week ago

The problem

Hi everyone,

I'm having an issue with the Signal CLI REST API and could use some help.

Problem:

When I receive a message using the Signal CLI REST API, I only get a UUID as the sender information. Here is an example of a received message:

[
  {
    "envelope": {
      "source": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "sourceNumber": null,
      "sourceUuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "sourceName": "xxxx",
      "sourceDevice": 4,
      "timestamp": 1718816184062,
      "dataMessage": {
        "timestamp": 1718816184062,
        "message": "Test",
        "expiresInSeconds": 0,
        "viewOnce": false
      }
    },
    "account": "+49xxxxxxxxxxxxx"
  }
]

As you can see, I only get the UUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) as the sender information.

Question:

How can I reply to this message when I only have the UUID? I tried sending a message using the following curl command, but it doesn't work:

curl -X POST -H "Content-Type: application/json" \
-d '{
  "message": "Hello!",
  "number": "+49xxxxxxxxxxxxx",
  "recipients": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"]
}' \
https://example.com/signal/v2/send

I receive the following error:

{"error":"java.lang.RuntimeException: org.signal.libsignal.usernames.MissingSeparatorException: Username must contain a '.'\n\tat org.asamk.signal.manager.helper.RecipientHelper.resolveRecipientByUsernameOrLink(RecipientHelper.java:105)\n\tat org.asamk.signal.manager.helper.RecipientHelper.resolveRecipient(RecipientHelper.java:93)\n\tat org.asamk.signal.manager.internal.ManagerImpl.sendMessage(ManagerImpl.java:622)\n\tat org.asamk.signal.manager.internal.ManagerImpl.sendMessage(ManagerImpl.java:598)\n\tat org.asamk.signal.manager.internal.ManagerImpl.sendMessage(ManagerImpl.java:726)\n\tat org.asamk.signal.commands.SendCommand.handleCommand(SendCommand.java:245)\n\tat org.asamk.signal.commands.CommandHandler.handleLocalCommand(CommandHandler.java:35)\n\tat org.asamk.signal.App.handleLocalCommand(App.java:278)\n\tat org.asamk.signal.App.handleCommand(App.java:179)\n\tat org.asamk.signal.App.init(App.java:144)\n\tat org.asamk.signal.Main.main(Main.java:56)\nCaused by: org.signal.libsignal.usernames.MissingSeparatorException: Username must contain a '.'\n\tat org.signal.libsignal.internal.Native.Username_Hash(Native Method)\n\tat org.signal.libsignal.usernames.Username.lambda$hash$6(Username.java:148)\n\tat org.signal.libsignal.internal.FilterExceptions.filterExceptions(FilterExceptions.java:143)\n\tat org.signal.libsignal.usernames.Username.hash(Username.java:148)\n\tat org.signal.libsignal.usernames.Username.\u003cinit\u003e(Username.java:57)\n\tat org.asamk.signal.manager.helper.RecipientHelper.getUsernameFromUsernameOrLink(RecipientHelper.java:137)\n\tat org.asamk.signal.manager.helper.RecipientHelper.resolveRecipientByUsernameOrLink(RecipientHelper.java:103)\n\t... 10 more\n"}

It seems like the UUID is being interpreted as a username, which must contain a . (there is a similar question open but it does not mention the uuid problem). Is there a way to send a message directly to a UUID, or do I need to identify the sender differently? Am I perhaps using the API request incorrectly?

Any help or example request would be greatly appreciated!

Thank you in advance!

Are you using the latest released version?

Have you read the troubleshooting page?

What type of installation are you running?

signal-cli-rest-api Docker Container

In which mode are you using the docker container?

Normal Mode

What's the architecture of your host system?

x86-64

Additional information

No response

tzindler commented 1 week ago

Addendum: With the v1 endpoint, everything works as it should with the same contacts.

bbernhard commented 1 week ago

should be fixed now and will be available with the next release

Era-Dorta commented 1 week ago

@bbernhard do you have an ETA on when is the release coming out?

bbernhard commented 1 week ago

I guess in a few days. If you want to give it a try, you can use this dev version: bbernhard/signal-cli-rest-api:0.162-dev

mattwr18 commented 4 days ago

@bbernhard tested it and it works for me :tada: