signal-cli-rest-api icon indicating copy to clipboard operation
signal-cli-rest-api copied to clipboard

Send Reaction Endpoint Not Working

Open NikhilMasc opened this issue 10 months ago • 13 comments

The problem

Hi,

I have been using the API for a few months now and it seems like every endpoint works perfectly except for the SendReaction endpoint. I am sending a POST request to http://127.0.0.1:8080/v1/reactions/<my number> with the body:

{ "reaction": "👍", "recipient": "<recipient number>", "target_author": "<recipient number>", "timestamp": <timestamp of message I am reacting to> }

Am I doing something wrong here?

Are you using the latest released version?

  • [x] Yes

Have you read the troubleshooting page?

  • [x] Yes

What type of installation are you running?

signal-cli-rest-api Docker Container

In which mode are you using the docker container?

Native Mode

What's the architecture of your host system?

x86-64

Additional information

No response

NikhilMasc avatar Jan 16 '25 23:01 NikhilMasc

What's the HTTP status code of the response? Do you get any error back from the API? Do you see any errors in the log?

bbernhard avatar Jan 18 '25 23:01 bbernhard

The request returns status code 204 with no error. I just double checked the log and there are no errors there either. Even though it seems like it should work, there is no reaction attached to the message when I check Signal.

NikhilMasc avatar Jan 18 '25 23:01 NikhilMasc

Strange...works for me.

Are you sure, that the recipient, target_author and timestamp are correctly set?

bbernhard avatar Jan 19 '25 19:01 bbernhard

I am using it like this:

I receive a message with the following:

"envelope": { "source": <source_id>, "sourceNumber": null, "sourceUuid": <source_id>, "sourceName": "Person XYZ", "sourceDevice": 2, "timestamp": 1737656436592, "serverReceivedTimestamp": 1737656435278, "serverDeliveredTimestamp": 1737656443637, "dataMessage": { "timestamp": 1737656436592, "message": "hi", "expiresInSeconds": 0, "viewOnce": false } }

I then send a POST request to http://127.0.0.1:8080/v1/reactions/<my number> with the body:

{ "reaction": "👍", "recipient": <source_id>, "target_author": <source_id>, "timestamp": 1737656436592 }

The response code is 204, but when I check Signal there is no reaction attached to the message.

Could you please let me know if I am using it correctly?

NikhilMasc avatar Jan 23 '25 18:01 NikhilMasc

That looks okay to me. The source_id is the recipient's number starting with +..., right?

How did you send the the request? with curl?

bbernhard avatar Jan 23 '25 18:01 bbernhard

The source_id is the "sourceUuid" of the Signal user. Since some people hide their phone number on Signal, I use the uuid instead. The uuid works for sending messages to the recipient, so I assumed the same would work for sending a reaction.

I also just tested it out with the recipient's number and it still does not work for me.

I am using Postman to send my test requests and the Python requests library for the actual program.

NikhilMasc avatar Jan 23 '25 18:01 NikhilMasc

The source_id is the "sourceUuid" of the Signal user. Since some people hide their phone number on Signal, I use the uuid instead. The uuid works for sending messages to the recipient, so I assumed the same would work for sending a reaction.

I also just tested it out with the recipient's number and it still does not work for me.

I am using Postman to send my test requests and the Python requests library for the actual program.

I just tested it and the underlying signal-cli (which the REST API wrapper is based on) does not do much sanity checking. So e.g if you pass something invalid (e.g some text string) to the reaction, it would still return "everything is fine", but nothing is shown in Signal.

Could it be, that Postman maybe can't handle the "👍" properly and maybe sends differently encoded characters to the REST API endpoint?

In order to test that, you could enable the debug mode (https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/DEBUG.md) and check in the logs how the actual signal-cli command looks like.

bbernhard avatar Jan 23 '25 19:01 bbernhard

I just enabled debug mode and found the following logged in docker:

time="2025-01-23T19:12:31Z" level=debug msg="*) signal-cli --config /home/.local/share/signal-cli -a <my_number> sendReaction <source_number> -e 👍 -a <source_number> -t 1737659440753"

Does this look correct?

NikhilMasc avatar Jan 23 '25 19:01 NikhilMasc

After some testing, I discovered that it works when I execute the following bash commands within the container:

apt-get update && apt-get install -y locales

locale-gen en_US.UTF-8

update-locale LANG=en_US.UTF-8

export LC_ALL=en_US.UTF-8

Would it be possible to modify the Dockerfile in the next release to include these?

NikhilMasc avatar Jan 23 '25 23:01 NikhilMasc

I still don't get why it doesn't work for you. What character enconding do you use? UTF8?

bbernhard avatar Jan 23 '25 23:01 bbernhard

Yes, I'm using UTF8 encoding. I found this issue: https://github.com/AsamK/signal-cli/issues/1449 and realized that the issue might be with the Docker locales on Windows. When I generated and set the locales within the container, the issue was fixed.

NikhilMasc avatar Jan 24 '25 00:01 NikhilMasc

Does this image work for you: bbernhard/signal-cli-rest-api:0.177-dev?

bbernhard avatar Jan 28 '25 20:01 bbernhard

Hi, sorry I wasn't able to test this earlier and thank you for taking the time to make the change. I just tried it out and that image works perfectly.

I was also able to get it working by creating my own Dockerfile with the following:

FROM bbernhard/signal-cli-rest-api:latest

ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en

RUN apt-get update && apt-get install -y locales && \
    locale-gen en_US.UTF-8 && \
    update-locale LANG=en_US.UTF-8 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

Just out of curiosity, was this similar to the change you made in the new image?

NikhilMasc avatar Feb 05 '25 01:02 NikhilMasc

Just out of curiosity, was this similar to the change you made in the new image?

Sorry, didn't see that message. That's the changeset: https://github.com/bbernhard/signal-cli-rest-api/commit/0eeb51da1971936c3386dc3eae023fd323551597

bbernhard avatar Mar 14 '25 19:03 bbernhard