diff --git a/CHANGELOG.md b/CHANGELOG.md index 688432de3..5bd95e37e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ - `messageGetWebxdcInfo` -> `getWebxdcInfo` - jsonrpc: changed method signature - `miscSendTextMessage(accountId, text, chatId)` -> `miscSendTextMessage(accountId, chatId, text)` +- jsonrpc: add `SystemMessageType` to `Message` +- cffi: add missing `DC_INFO_` constants diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 8417a81ef..ccb084c91 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -4097,9 +4097,19 @@ int dc_msg_get_info_type (const dc_msg_t* msg); // DC_INFO* uses the same values as SystemMessage in rust-land -#define DC_INFO_PROTECTION_ENABLED 11 -#define DC_INFO_PROTECTION_DISABLED 12 - +#define DC_INFO_UNKNOWN 0 +#define DC_INFO_GROUP_NAME_CHANGED 2 +#define DC_INFO_GROUP_IMAGE_CHANGED 3 +#define DC_INFO_MEMBER_ADDED_TO_GROUP 4 +#define DC_INFO_MEMBER_REMOVED_FROM_GROUP 5 +#define DC_INFO_AUTOCRYPT_SETUP_MESSAGE 6 +#define DC_INFO_SECURE_JOIN_MESSAGE 7 +#define DC_INFO_LOCATIONSTREAMING_ENABLED 8 +#define DC_INFO_LOCATION_ONLY 9 +#define DC_INFO_EPHEMERAL_TIMER_CHANGED 10 +#define DC_INFO_PROTECTION_ENABLED 11 +#define DC_INFO_PROTECTION_DISABLED 12 +#define DC_INFO_WEBXDC_INFO_MESSAGE 32 /** * Check if a message is still in creation. A message is in creation between diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index 181cbb621..6e5737415 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -45,6 +45,8 @@ pub struct MessageObject { is_setupmessage: bool, is_info: bool, is_forwarded: bool, + /// when is_info is true this describes what type of system message it is + system_message_type: SystemMessageType, duration: i32, dimensions_height: i32, @@ -175,6 +177,7 @@ impl MessageObject { is_setupmessage: message.is_setupmessage(), is_info: message.is_info(), is_forwarded: message.is_forwarded(), + system_message_type: message.get_info_type().into(), duration: message.get_duration(), dimensions_height: message.get_height(), @@ -305,6 +308,61 @@ impl From for DownloadState { } } +#[derive(Serialize, TypeDef)] +pub enum SystemMessageType { + Unknown, + GroupNameChanged, + GroupImageChanged, + MemberAddedToGroup, + MemberRemovedFromGroup, + AutocryptSetupMessage, + SecurejoinMessage, + LocationStreamingEnabled, + LocationOnly, + + /// Chat ephemeral message timer is changed. + EphemeralTimerChanged, + + // Chat protection state changed + ChatProtectionEnabled, + ChatProtectionDisabled, + + /// Self-sent-message that contains only json used for multi-device-sync; + /// if possible, we attach that to other messages as for locations. + MultiDeviceSync, + + // Sync message that contains a json payload + // sent to the other webxdc instances + // These messages are not shown in the chat. + WebxdcStatusUpdate, + + /// Webxdc info added with `info` set in `send_webxdc_status_update()`. + WebxdcInfoMessage, +} + +impl From for SystemMessageType { + fn from(system_message_type: deltachat::mimeparser::SystemMessage) -> Self { + use deltachat::mimeparser::SystemMessage; + match system_message_type { + SystemMessage::Unknown => SystemMessageType::Unknown, + SystemMessage::GroupNameChanged => SystemMessageType::GroupNameChanged, + SystemMessage::GroupImageChanged => SystemMessageType::GroupImageChanged, + SystemMessage::MemberAddedToGroup => SystemMessageType::MemberAddedToGroup, + SystemMessage::MemberRemovedFromGroup => SystemMessageType::MemberRemovedFromGroup, + SystemMessage::AutocryptSetupMessage => SystemMessageType::AutocryptSetupMessage, + SystemMessage::SecurejoinMessage => SystemMessageType::SecurejoinMessage, + SystemMessage::LocationStreamingEnabled => SystemMessageType::LocationStreamingEnabled, + SystemMessage::LocationOnly => SystemMessageType::LocationOnly, + SystemMessage::EphemeralTimerChanged => SystemMessageType::EphemeralTimerChanged, + SystemMessage::ChatProtectionEnabled => SystemMessageType::ChatProtectionEnabled, + SystemMessage::ChatProtectionDisabled => SystemMessageType::ChatProtectionDisabled, + SystemMessage::MultiDeviceSync => SystemMessageType::MultiDeviceSync, + SystemMessage::WebxdcStatusUpdate => SystemMessageType::WebxdcStatusUpdate, + SystemMessage::WebxdcInfoMessage => SystemMessageType::WebxdcInfoMessage, + } + } +} + #[derive(Serialize, TypeDef)] #[serde(rename_all = "camelCase")] pub struct MessageNotificationInfo { diff --git a/deltachat-jsonrpc/typescript/generated/constants.ts b/deltachat-jsonrpc/typescript/generated/constants.ts index 3f50b6653..ea0ba57dc 100644 --- a/deltachat-jsonrpc/typescript/generated/constants.ts +++ b/deltachat-jsonrpc/typescript/generated/constants.ts @@ -29,8 +29,6 @@ export enum C { DC_GCL_VERIFIED_ONLY = 1, DC_GCM_ADDDAYMARKER = 1, DC_GCM_INFO_ONLY = 2, - DC_INFO_PROTECTION_DISABLED = 12, - DC_INFO_PROTECTION_ENABLED = 11, DC_KEY_GEN_DEFAULT = 0, DC_KEY_GEN_ED25519 = 2, DC_KEY_GEN_RSA2048 = 1, diff --git a/deltachat-jsonrpc/typescript/generated/types.ts b/deltachat-jsonrpc/typescript/generated/types.ts index 9b2dcacc2..d55bde227 100644 --- a/deltachat-jsonrpc/typescript/generated/types.ts +++ b/deltachat-jsonrpc/typescript/generated/types.ts @@ -108,6 +108,20 @@ export type Viewtype=("Unknown"| */ "Webxdc"); export type MessageQuote=(({"kind":"JustText";}&{"text":string;})|({"kind":"WithMessage";}&{"text":string;"messageId":U32;"authorDisplayName":string;"authorDisplayColor":string;"overrideSenderName":(string|null);"image":(string|null);"isForwarded":boolean;"viewType":Viewtype;})); +export type SystemMessageType=("Unknown"|"GroupNameChanged"|"GroupImageChanged"|"MemberAddedToGroup"|"MemberRemovedFromGroup"|"AutocryptSetupMessage"|"SecurejoinMessage"|"LocationStreamingEnabled"|"LocationOnly"| +/** + * Chat ephemeral message timer is changed. + */ +"EphemeralTimerChanged"|"ChatProtectionEnabled"|"ChatProtectionDisabled"| +/** + * Self-sent-message that contains only json used for multi-device-sync; + * if possible, we attach that to other messages as for locations. + */ +"MultiDeviceSync"|"WebxdcStatusUpdate"| +/** + * Webxdc info added with `info` set in `send_webxdc_status_update()`. + */ +"WebxdcInfoMessage"); export type I32=number; export type WebxdcMessageInfo={ /** @@ -164,7 +178,11 @@ export type Reactions= * Unique reactions and their count */ "reactions":Record;}; -export type Message={"id":U32;"chatId":U32;"fromId":U32;"quote":(MessageQuote|null);"parentId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);"webxdcInfo":(WebxdcMessageInfo|null);"downloadState":DownloadState;"reactions":(Reactions|null);}; +export type Message={"id":U32;"chatId":U32;"fromId":U32;"quote":(MessageQuote|null);"parentId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean; +/** + * when is_info is true this describes what type of system message it is + */ +"systemMessageType":SystemMessageType;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);"webxdcInfo":(WebxdcMessageInfo|null);"downloadState":DownloadState;"reactions":(Reactions|null);}; export type MessageNotificationInfo={"id":U32;"chatId":U32;"accountId":U32;"image":(string|null);"imageMimeType":(string|null);"chatName":string;"chatProfileImage":(string|null); /** * also known as summary_text1 diff --git a/deltachat-jsonrpc/typescript/scripts/generate-constants.js b/deltachat-jsonrpc/typescript/scripts/generate-constants.js index 525a9d42b..4f20a5038 100755 --- a/deltachat-jsonrpc/typescript/scripts/generate-constants.js +++ b/deltachat-jsonrpc/typescript/scripts/generate-constants.js @@ -38,6 +38,7 @@ const constants = data key.startsWith("DC_IMEX_") || key.startsWith("DC_CHAT_VISIBILITY") || key.startsWith("DC_DOWNLOAD") || + key.startsWith("DC_INFO_") || (key.startsWith("DC_MSG") && !key.startsWith("DC_MSG_ID")) || key.startsWith("DC_QR_") ); diff --git a/node/constants.js b/node/constants.js index ba5bd1a71..5b6c401a9 100644 --- a/node/constants.js +++ b/node/constants.js @@ -71,8 +71,19 @@ module.exports = { DC_IMEX_EXPORT_SELF_KEYS: 1, DC_IMEX_IMPORT_BACKUP: 12, DC_IMEX_IMPORT_SELF_KEYS: 2, + DC_INFO_AUTOCRYPT_SETUP_MESSAGE: 6, + DC_INFO_EPHEMERAL_TIMER_CHANGED: 10, + DC_INFO_GROUP_IMAGE_CHANGED: 3, + DC_INFO_GROUP_NAME_CHANGED: 2, + DC_INFO_LOCATIONSTREAMING_ENABLED: 8, + DC_INFO_LOCATION_ONLY: 9, + DC_INFO_MEMBER_ADDED_TO_GROUP: 4, + DC_INFO_MEMBER_REMOVED_FROM_GROUP: 5, DC_INFO_PROTECTION_DISABLED: 12, DC_INFO_PROTECTION_ENABLED: 11, + DC_INFO_SECURE_JOIN_MESSAGE: 7, + DC_INFO_UNKNOWN: 0, + DC_INFO_WEBXDC_INFO_MESSAGE: 32, DC_KEY_GEN_DEFAULT: 0, DC_KEY_GEN_ED25519: 2, DC_KEY_GEN_RSA2048: 1, diff --git a/node/lib/constants.ts b/node/lib/constants.ts index 5b32cf7e5..594d54626 100644 --- a/node/lib/constants.ts +++ b/node/lib/constants.ts @@ -71,8 +71,19 @@ export enum C { DC_IMEX_EXPORT_SELF_KEYS = 1, DC_IMEX_IMPORT_BACKUP = 12, DC_IMEX_IMPORT_SELF_KEYS = 2, + DC_INFO_AUTOCRYPT_SETUP_MESSAGE = 6, + DC_INFO_EPHEMERAL_TIMER_CHANGED = 10, + DC_INFO_GROUP_IMAGE_CHANGED = 3, + DC_INFO_GROUP_NAME_CHANGED = 2, + DC_INFO_LOCATIONSTREAMING_ENABLED = 8, + DC_INFO_LOCATION_ONLY = 9, + DC_INFO_MEMBER_ADDED_TO_GROUP = 4, + DC_INFO_MEMBER_REMOVED_FROM_GROUP = 5, DC_INFO_PROTECTION_DISABLED = 12, DC_INFO_PROTECTION_ENABLED = 11, + DC_INFO_SECURE_JOIN_MESSAGE = 7, + DC_INFO_UNKNOWN = 0, + DC_INFO_WEBXDC_INFO_MESSAGE = 32, DC_KEY_GEN_DEFAULT = 0, DC_KEY_GEN_ED25519 = 2, DC_KEY_GEN_RSA2048 = 1,