AsamK / signal-cli

signal-cli provides an unofficial commandline, JSON-RPC and dbus interface for the Signal messenger.
GNU General Public License v3.0
3.14k stars 297 forks source link

Feature Request: Use contact names for JSON HTTP output #1577

Open jyundt opened 2 weeks ago

jyundt commented 2 weeks ago

Currently the JSON payload returned in daemon/http mode does not resolve properties like destination and author to the "friendly" contact names; just the numeric value.

As an example: below is stdout when running in daemon/http mode (I've slightly redacted my phone number for reference):

jyundt@athena:~/Downloads/signal-cli-0.13.5/bin$ ~/git/signal-cli/build/install/signal-cli/bin/signal-cli --verbose daemon --http --receive-mode on-connection 
2024-09-01T12:17:40.345-0400 [main] DEBUG org.asamk.signal.App - Starting signal-cli 0.13.6-SNAPSHOT
2024-09-01T12:17:40.539-0400 [main] DEBUG org.asamk.signal.util.IOUtils - XDG_DATA_HOME not set, falling back to home dir
2024-09-01T12:17:40.710-0400 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2024-09-01T12:17:40.786-0400 [main] INFO  com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.sqlite.jdbc4.JDBC4Connection@5b529706
2024-09-01T12:17:40.787-0400 [main] INFO  com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2024-09-01T12:17:41.531-0400 [main] INFO  o.a.signal.commands.DaemonCommand - Starting daemon in multi-account mode
2024-09-01T12:17:41.540-0400 [main] DEBUG o.a.signal.http.HttpServerHandler - Starting HTTP server on localhost/127.0.0.1:8080
2024-09-01T12:17:41.545-0400 [main] INFO  o.a.signal.http.HttpServerHandler - Started HTTP server on localhost/127.0.0.1:8080
2024-09-01T12:18:00.117-0400 [receive-0] DEBUG o.a.s.manager.internal.ManagerImpl - Starting receiving messages
2024-09-01T12:18:00.159-0400 [receive-0] INFO  LibSignal - [OkHttpWebSocketConnection]: [normal:2028256546] connect()
2024-09-01T12:18:00.166-0400 [receive-0] INFO  LibSignal - [OkHttpWebSocketConnection]: [unidentified:621722682] connect()
2024-09-01T12:18:00.170-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Handling message actions
2024-09-01T12:18:00.177-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Checking for new message from server
2024-09-01T12:18:00.283-0400 [OkHttp https://chat.signal.org/...] INFO  LibSignal - [OkHttpWebSocketConnection]: [unidentified:621722682] onOpen() connected
2024-09-01T12:18:00.283-0400 [OkHttp https://chat.signal.org/...] INFO  LibSignal - [OkHttpWebSocketConnection]: [normal:2028256546] onOpen() connected
2024-09-01T12:18:00.283-0400 [RxComputationThreadPool-5] DEBUG o.a.s.m.i.SignalWebSocketHealthMonitor - WebSocket is now connected
2024-09-01T12:18:00.284-0400 [RxComputationThreadPool-4] DEBUG o.a.s.m.i.SignalWebSocketHealthMonitor - WebSocket is now connected
2024-09-01T12:18:00.302-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Retrieved 1 envelopes!
2024-09-01T12:18:00.312-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - New message received from server
2024-09-01T12:18:00.352-0400 [receive-0] DEBUG o.a.s.m.s.recipients.RecipientStore - Marking RecipientId[id=1] numbers as need pni signature = false
Envelope from: “Jacob Yundt” +16468675309 (device: 2) to +16468675309
Timestamp: 1725207471615 (2024-09-01T16:17:51.615Z)
Server timestamps: received: 1725207471685 (2024-09-01T16:17:51.685Z) delivered: 1725207480277 (2024-09-01T16:18:00.277Z)
Received a sync message
Received sync sent message
  To: “Jacob Yundt” +16468675309
  Timestamp: 1725207471615 (2024-09-01T16:17:51.615Z)
  Expiration started at: 1725207471665 (2024-09-01T16:17:51.665Z)
  Message timestamp: 1725207471615 (2024-09-01T16:17:51.615Z)
  Body: sending a message to myself
  With profile key

2024-09-01T12:18:00.403-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Checking for new message from server
2024-09-01T12:18:00.403-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Received indicator that server queue is empty
2024-09-01T12:18:00.403-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Handling message actions
2024-09-01T12:18:00.404-0400 [receive-0] DEBUG o.a.s.manager.internal.JobExecutor - Running CleanOldPreKeysJob job
2024-09-01T12:18:00.404-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Checking for new message from server
2024-09-01T12:18:23.309-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Retrieved 1 envelopes!
2024-09-01T12:18:23.312-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - New message received from server
2024-09-01T12:18:23.323-0400 [receive-0] DEBUG o.a.s.m.s.recipients.RecipientStore - Marking RecipientId[id=1] numbers as need pni signature = false
Envelope from: “Jacob Yundt” +16468675309 (device: 2) to +16468675309
Timestamp: 1725207503189 (2024-09-01T16:18:23.189Z)
Server timestamps: received: 1725207503296 (2024-09-01T16:18:23.296Z) delivered: 1725207503298 (2024-09-01T16:18:23.298Z)
Received a sync message
Received sync sent message
  To: “Jacob Yundt” +16468675309
  Timestamp: 1725207503189 (2024-09-01T16:18:23.189Z)
  Expiration started at: 1725207503260 (2024-09-01T16:18:23.260Z)
  Message timestamp: 1725207503189 (2024-09-01T16:18:23.189Z)
  Body: replying to myself
  With profile key
  Quote:
    Id: 1725207471615
    Author: “Jacob Yundt” +16468675309
    Text: sending a message to myself

2024-09-01T12:18:23.355-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Handling message actions
2024-09-01T12:18:23.356-0400 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Checking for new message from server
2024-09-01T12:18:30.285-0400 [Thread-2] INFO  LibSignal - [OkHttpWebSocketConnection]: [normal:2028256546] Sending keep alive...
2024-09-01T12:18:30.287-0400 [Thread-2] INFO  LibSignal - [OkHttpWebSocketConnection]: [unidentified:621722682] Sending keep alive...

However, the returned JSON payload does not resolve my number (6468675309) to my contact name / friendly name:

    "envelope": {
        "source": "+16468675309",
        "sourceNumber": "+16468675309",
        "sourceUuid": "3b2187da-d6e2-4b59-8484-e6a1e2439bd9",
        "sourceName": "Jacob Yundt",
        "sourceDevice": 2,
        "timestamp": 1725207471615,
        "syncMessage": {
            "sentMessage": {
                "destination": "+16468675309",
                "destinationNumber": "+16468675309",
                "destinationUuid": "3b2187da-d6e2-4b59-8484-e6a1e2439bd9",
                "timestamp": 1725207471615,
                "message": "sending a message to myself",
                "expiresInSeconds": 0,
                "viewOnce": false
            }
        }
    },
    "account": "+16468675309"
}
{
    "envelope": {
        "source": "+16468675309",
        "sourceNumber": "+16468675309",
        "sourceUuid": "3b2187da-d6e2-4b59-8484-e6a1e2439bd9",
        "sourceName": "Jacob Yundt",
        "sourceDevice": 2,
        "timestamp": 1725207503189,
        "syncMessage": {
            "sentMessage": {
                "destination": "+16468675309",
                "destinationNumber": "+16468675309",
                "destinationUuid": "3b2187da-d6e2-4b59-8484-e6a1e2439bd9",
                "timestamp": 1725207503189,
                "message": "replying to myself",
                "expiresInSeconds": 0,
                "viewOnce": false,
                "quote": {
                    "id": 1725207471615,
                    "author": "+16468675309",
                    "authorNumber": "+16468675309",
                    "authorUuid": "3b2187da-d6e2-4b59-8484-e6a1e2439bd9",
                    "text": "sending a message to myself",
                    "attachments": []
                }
            }
        }
    },
    "account": "+16468675309"
}

Could this behavior be changed so that envelope.syncMessage.sentMessage.destination and envelope.syncMessage.sentMessage.quote.author resolve to friendly name / contact names similar to the stdout output?

I was able to reproduce this behavior on both $LATEST (cb129db) and the official v0.13.5 release.

Using author as an example, it looks to be using getLegacyIdentifier(), could this use something like getContactOrProfileName()?

AsamK commented 1 week ago

Changing the author field is not possible, but adding an additional authorName field would work.