From 620d86c903ef4cf4eefd9516a84026f28ed45256 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 23 Jan 2026 17:41:25 +0100 Subject: [PATCH] update RPC bindings --- src/main/java/chat/delta/rpc/Rpc.java | 43 ++++++++++++++++--- .../java/chat/delta/rpc/types/BasicChat.java | 2 +- .../java/chat/delta/rpc/types/Contact.java | 2 +- .../java/chat/delta/rpc/types/EventType.java | 4 +- .../java/chat/delta/rpc/types/FullChat.java | 1 - .../java/chat/delta/rpc/types/Message.java | 1 + .../delta/rpc/types/MessageLoadResult.java | 1 + 7 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/main/java/chat/delta/rpc/Rpc.java b/src/main/java/chat/delta/rpc/Rpc.java index e36451085..4cccc26ce 100644 --- a/src/main/java/chat/delta/rpc/Rpc.java +++ b/src/main/java/chat/delta/rpc/Rpc.java @@ -211,11 +211,11 @@ public class Rpc { } /** - * Set configuration values from a QR code. (technically from the URI that is stored in the qrcode) - * Before this function is called, `checkQr()` should confirm the type of the - * QR code is `account` or `webrtcInstance`. + * Set configuration values from a QR code (technically from the URI stored in it). + * Before this function is called, `check_qr()` should be used to get the QR code type. *

- * Internally, the function will call dc_set_config() with the appropriate keys, + * "DCACCOUNT:" and "DCLOGIN:" QR codes configure the account, but I/O mustn't be started for + * such QR codes, consider using [`Self::add_transport_from_qr`] which also restarts I/O. */ public void setConfigFromQr(Integer accountId, String qrContent) throws RpcException { transport.call("set_config_from_qr", mapper.valueToTree(accountId), mapper.valueToTree(qrContent)); @@ -234,6 +234,11 @@ public class Rpc { return transport.callForResult(new TypeReference>(){}, "batch_get_config", mapper.valueToTree(accountId), mapper.valueToTree(keys)); } + /** Returns all `ui.*` config keys that were set by the UI. */ + public java.util.List getAllUiConfigKeys(Integer accountId) throws RpcException { + return transport.callForResult(new TypeReference>(){}, "get_all_ui_config_keys", mapper.valueToTree(accountId)); + } + public void setStockStrings(java.util.Map strings) throws RpcException { transport.call("set_stock_strings", mapper.valueToTree(strings)); } @@ -449,11 +454,11 @@ public class Rpc { * Delete a chat. *

* Messages are deleted from the device and the chat database entry is deleted. - * After that, the event #DC_EVENT_MSGS_CHANGED is posted. + * After that, a `MsgsChanged` event is emitted. + * Messages are deleted from the server in background. *

* Things that are _not done_ implicitly: *

- * - Messages are **not deleted from the server**. * - The chat or the contact is **not blocked**, so new messages from the user/the group may appear as a contact request * and the user may create the chat again. * - **Groups are not left** - this would @@ -733,11 +738,26 @@ public class Rpc { return transport.callForResult(new TypeReference(){}, "add_device_message", mapper.valueToTree(accountId), mapper.valueToTree(label), mapper.valueToTree(msg)); } + /** + * Mark all messages in all chats as _noticed_. + * Skips messages from blocked contacts, but does not skip messages in muted chats. + *

+ * _Noticed_ messages are no longer _fresh_ and do not count as being unseen + * but are still waiting for being marked as "seen" using markseen_msgs() + * (read receipts aren't sent for noticed messages). + *

+ * Calling this function usually results in the event #DC_EVENT_MSGS_NOTICED. + * See also markseen_msgs(). + */ + public void marknoticedAllChats(Integer accountId) throws RpcException { + transport.call("marknoticed_all_chats", mapper.valueToTree(accountId)); + } + /** * Mark all messages in a chat as _noticed_. * _Noticed_ messages are no longer _fresh_ and do not count as being unseen * but are still waiting for being marked as "seen" using markseen_msgs() - * (IMAP/MDNs is not done for noticed messages). + * (read receipts aren't sent for noticed messages). *

* Calling this function usually results in the event #DC_EVENT_MSGS_NOTICED. * See also markseen_msgs(). @@ -893,6 +913,15 @@ public class Rpc { return transport.callForResult(new TypeReference(){}, "get_message_info_object", mapper.valueToTree(accountId), mapper.valueToTree(messageId)); } + /** + * Returns count of read receipts on message. + *

+ * This view count is meant as a feedback measure for the channel owner only. + */ + public Integer getMessageReadReceiptCount(Integer accountId, Integer messageId) throws RpcException { + return transport.callForResult(new TypeReference(){}, "get_message_read_receipt_count", mapper.valueToTree(accountId), mapper.valueToTree(messageId)); + } + /** Returns contacts that sent read receipts and the time of reading. */ public java.util.List getMessageReadReceipts(Integer accountId, Integer messageId) throws RpcException { return transport.callForResult(new TypeReference>(){}, "get_message_read_receipts", mapper.valueToTree(accountId), mapper.valueToTree(messageId)); diff --git a/src/main/java/chat/delta/rpc/types/BasicChat.java b/src/main/java/chat/delta/rpc/types/BasicChat.java index 5ca3526fe..e470a2e55 100644 --- a/src/main/java/chat/delta/rpc/types/BasicChat.java +++ b/src/main/java/chat/delta/rpc/types/BasicChat.java @@ -2,7 +2,7 @@ package chat.delta.rpc.types; /** - * cheaper version of fullchat, omits: - contacts - contact_ids - fresh_message_counter - ephemeral_timer - self_in_group - was_seen_recently - can_send + * cheaper version of fullchat, omits: - contact_ids - fresh_message_counter - ephemeral_timer - self_in_group - was_seen_recently - can_send *

* used when you only need the basic metadata of a chat like type, name, profile picture */ diff --git a/src/main/java/chat/delta/rpc/types/Contact.java b/src/main/java/chat/delta/rpc/types/Contact.java index 667f12646..6d6f3e064 100644 --- a/src/main/java/chat/delta/rpc/types/Contact.java +++ b/src/main/java/chat/delta/rpc/types/Contact.java @@ -38,7 +38,7 @@ public class Contact { *

* UI should display the information in the contact's profile as follows: *

- * - If `verifierId` != 0, display text "Introduced by ..." with the name and address of the contact formatted by `name_and_addr`/`nameAndAddr`. Prefix the text by a green checkmark. + * - If `verifierId` != 0, display text "Introduced by ..." with the name of the contact. Prefix the text by a green checkmark. *

* - If `verifierId` == 0 and `isVerified` != 0, display "Introduced" prefixed by a green checkmark. *

diff --git a/src/main/java/chat/delta/rpc/types/EventType.java b/src/main/java/chat/delta/rpc/types/EventType.java index 985bb45de..a77bae4a6 100644 --- a/src/main/java/chat/delta/rpc/types/EventType.java +++ b/src/main/java/chat/delta/rpc/types/EventType.java @@ -412,7 +412,9 @@ public abstract class EventType { /** * One or more transports has changed. *

- * This event is used for tests to detect when transport synchronization messages arrives. UIs don't need to use it, it is unlikely that user modifies transports on multiple devices simultaneously. + * UI should update the list. + *

+ * This event is emitted when transport synchronization messages arrives, but not when the UI modifies the transport list by itself. */ public static class TransportsModified extends EventType { } diff --git a/src/main/java/chat/delta/rpc/types/FullChat.java b/src/main/java/chat/delta/rpc/types/FullChat.java index a1b4f46a7..c8b424d6a 100644 --- a/src/main/java/chat/delta/rpc/types/FullChat.java +++ b/src/main/java/chat/delta/rpc/types/FullChat.java @@ -7,7 +7,6 @@ public class FullChat { public ChatType chatType; public String color; public java.util.List contactIds; - public java.util.List contacts; public Integer ephemeralTimer; public Integer freshMessageCounter; public Integer id; diff --git a/src/main/java/chat/delta/rpc/types/Message.java b/src/main/java/chat/delta/rpc/types/Message.java index fcf4351a0..2087e6e0d 100644 --- a/src/main/java/chat/delta/rpc/types/Message.java +++ b/src/main/java/chat/delta/rpc/types/Message.java @@ -12,6 +12,7 @@ public class Message { public String error; @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SET) public String file; + /** The size of the file in bytes, if applicable. If message is a pre-message, then this is the size of the file to be downloaded. */ public Integer fileBytes; @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SET) public String fileMime; diff --git a/src/main/java/chat/delta/rpc/types/MessageLoadResult.java b/src/main/java/chat/delta/rpc/types/MessageLoadResult.java index 0d7838675..80fb198b2 100644 --- a/src/main/java/chat/delta/rpc/types/MessageLoadResult.java +++ b/src/main/java/chat/delta/rpc/types/MessageLoadResult.java @@ -22,6 +22,7 @@ public abstract class MessageLoadResult { public String error; @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SET) public String file; + /** The size of the file in bytes, if applicable. If message is a pre-message, then this is the size of the file to be downloaded. */ public Integer fileBytes; @com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SET) public String fileMime;