bbernhard / signal-cli-rest-api

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

How to get the sticker pack key from a received message? #512

Closed continue47 closed 6 months ago

continue47 commented 7 months ago

When receiving a sticker, the receive API returns something like this:

{
  envelope: {
    source: '...',
    sourceNumber: '...',
    sourceUuid: '...',
    sourceName: 'Name',
    sourceDevice: 1,
    timestamp: 1251234342342,
    dataMessage: {
      timestamp: 1251234342342,
      message: null,
      expiresInSeconds: 0,
      viewOnce: false,
      sticker: { packId: '<pack id>', stickerId: 0 }
    }
  },
  account: '...'
}

To get the sticker pack, one must also have the pack key for it. I couldn't find anything about how to get the sticker pack key either through the API or other means. I'm thinking it must be accessible to the account since it's receiving the sticker, but I don't know how to access it.

Any ideas? Thanks.

continue47 commented 7 months ago

There is an "Add sticker pack" API which mentions this:

In order to add a sticker pack, browse to https://signalstickers.org/ and select the sticker pack you want to add. Then, press the "Add to Signal" button. If you look at the address bar in your browser you should see an URL in this format: https://signal.art/addstickers/#pack_id=XXX&pack_key=YYY, where XXX is the pack_id and YYY is the pack_key.

However, not all packs are listed there, for example custom packs that someone makes. Is there any way to get the sticker pack key from a received sticker, or even just that sticker itself instead of the whole pack?

bbernhard commented 7 months ago

I haven't sent/received any stickers. So I am not sure how signal-cli behaves in that regard. Have you checked if the received stickers are maybe already installed and listed here: https://bbernhard.github.io/signal-cli-rest-api/#/Sticker%20Packs/get_v1_sticker_packs__number_

The "Add sticker pack" API call doesn't help you much here, because it always downloads them from https://signalstickers.org/

continue47 commented 6 months ago

Thanks for the reply.

I managed to use https://api.signalstickers.org/v1/packs/ to fetch and cache the JSON object with the published stickers, and then find the stickers there. Only works for the ones that are available there, but still better than nothing. :)

I'm also testing your suggestion with checking already installed stickers, will report back.

continue47 commented 6 months ago

@bbernhard It looks like "List Installed Sticker Packs." API does indeed contain the key needed to download the sticker, as you suggested.

Thank you for the help!