Skip to content

Commit

Permalink
emit DC_EVENT_INCOMING_REACTION
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Oct 19, 2024
1 parent 180b83c commit 5ed0af2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions deltachat-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ pub unsafe extern "C" fn dc_event_get_id(event: *mut dc_event_t) -> libc::c_int
EventType::ErrorSelfNotInGroup(_) => 410,
EventType::MsgsChanged { .. } => 2000,
EventType::ReactionsChanged { .. } => 2001,
EventType::IncomingReaction { .. } => 2002,
EventType::IncomingMsg { .. } => 2005,
EventType::IncomingMsgBunch { .. } => 2006,
EventType::MsgsNoticed { .. } => 2008,
Expand Down Expand Up @@ -597,6 +598,7 @@ pub unsafe extern "C" fn dc_event_get_data1_int(event: *mut dc_event_t) -> libc:
| EventType::ErrorSelfNotInGroup(_)
| EventType::AccountsBackgroundFetchDone => 0,
EventType::ChatlistChanged => 0,
EventType::IncomingReaction { contact_id, .. } => contact_id.to_u32() as libc::c_int,
EventType::MsgsChanged { chat_id, .. }
| EventType::ReactionsChanged { chat_id, .. }
| EventType::IncomingMsg { chat_id, .. }
Expand Down Expand Up @@ -669,6 +671,7 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
| EventType::EventChannelOverflow { .. } => 0,
EventType::MsgsChanged { msg_id, .. }
| EventType::ReactionsChanged { msg_id, .. }
| EventType::IncomingReaction { msg_id, .. }
| EventType::IncomingMsg { msg_id, .. }
| EventType::MsgDelivered { msg_id, .. }
| EventType::MsgFailed { msg_id, .. }
Expand Down Expand Up @@ -754,6 +757,9 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
libc::memcpy(ptr, data.as_ptr() as *mut libc::c_void, data.len());
ptr as *mut libc::c_char
}
EventType::IncomingReaction { reaction, .. } => {
reaction.to_c_string().unwrap_or_default().into_raw()
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/events/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ pub enum EventType {
contact_id: ContactId,
},

/// Reactions for the message changed.
IncomingReaction {
/// ID of the contact whose reaction set is changed.
contact_id: ContactId,

/// ID of the message for which reactions were changed.
msg_id: MsgId,

/// The reaction.
reaction: String,
},

/// There is a fresh message. Typically, the user will show an notification
/// when receiving this message.
///
Expand Down
8 changes: 7 additions & 1 deletion src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,13 @@ async fn add_parts(
)
.await?;
if mime_parser.incoming && in_fresh {
// TODO: emit DC_EVENT_INCOMING_REACTION
if let Some((msg_id, _)) = rfc724_mid_exists(context, mime_in_reply_to).await? {
context.emit_event(EventType::IncomingReaction {
contact_id: from_id,
msg_id,
reaction: reaction_str,
});
}
}
}

Expand Down

0 comments on commit 5ed0af2

Please sign in to comment.