mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
feat: add IncomingReaction.chat_id (#6459)
For the same reasons as mentioned in #6356 and to streamline the "Incoming" Event API. (all have a chat_id)
This commit is contained in:
@@ -101,6 +101,7 @@ pub enum EventType {
|
|||||||
/// Incoming reaction, should be notified.
|
/// Incoming reaction, should be notified.
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
IncomingReaction {
|
IncomingReaction {
|
||||||
|
chat_id: u32,
|
||||||
contact_id: u32,
|
contact_id: u32,
|
||||||
msg_id: u32,
|
msg_id: u32,
|
||||||
reaction: String,
|
reaction: String,
|
||||||
@@ -335,10 +336,12 @@ impl From<CoreEventType> for EventType {
|
|||||||
contact_id: contact_id.to_u32(),
|
contact_id: contact_id.to_u32(),
|
||||||
},
|
},
|
||||||
CoreEventType::IncomingReaction {
|
CoreEventType::IncomingReaction {
|
||||||
|
chat_id,
|
||||||
contact_id,
|
contact_id,
|
||||||
msg_id,
|
msg_id,
|
||||||
reaction,
|
reaction,
|
||||||
} => IncomingReaction {
|
} => IncomingReaction {
|
||||||
|
chat_id: chat_id.to_u32(),
|
||||||
contact_id: contact_id.to_u32(),
|
contact_id: contact_id.to_u32(),
|
||||||
msg_id: msg_id.to_u32(),
|
msg_id: msg_id.to_u32(),
|
||||||
reaction: reaction.as_str().to_string(),
|
reaction: reaction.as_str().to_string(),
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ pub enum EventType {
|
|||||||
|
|
||||||
/// Reactions for the message changed.
|
/// Reactions for the message changed.
|
||||||
IncomingReaction {
|
IncomingReaction {
|
||||||
|
/// ID of the chat which the message belongs to.
|
||||||
|
chat_id: ChatId,
|
||||||
|
|
||||||
/// ID of the contact whose reaction set is changed.
|
/// ID of the contact whose reaction set is changed.
|
||||||
contact_id: ContactId,
|
contact_id: ContactId,
|
||||||
|
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ pub(crate) async fn set_msg_reaction(
|
|||||||
&& msg_id.get_state(context).await?.is_outgoing()
|
&& msg_id.get_state(context).await?.is_outgoing()
|
||||||
{
|
{
|
||||||
context.emit_event(EventType::IncomingReaction {
|
context.emit_event(EventType::IncomingReaction {
|
||||||
|
chat_id,
|
||||||
contact_id,
|
contact_id,
|
||||||
msg_id,
|
msg_id,
|
||||||
reaction,
|
reaction,
|
||||||
@@ -582,6 +583,7 @@ Here's my footer -- bob@example.net"
|
|||||||
|
|
||||||
async fn expect_incoming_reactions_event(
|
async fn expect_incoming_reactions_event(
|
||||||
t: &TestContext,
|
t: &TestContext,
|
||||||
|
expected_chat_id: ChatId,
|
||||||
expected_msg_id: MsgId,
|
expected_msg_id: MsgId,
|
||||||
expected_contact_id: ContactId,
|
expected_contact_id: ContactId,
|
||||||
expected_reaction: &str,
|
expected_reaction: &str,
|
||||||
@@ -599,10 +601,12 @@ Here's my footer -- bob@example.net"
|
|||||||
.await;
|
.await;
|
||||||
match event {
|
match event {
|
||||||
EventType::IncomingReaction {
|
EventType::IncomingReaction {
|
||||||
|
chat_id,
|
||||||
msg_id,
|
msg_id,
|
||||||
contact_id,
|
contact_id,
|
||||||
reaction,
|
reaction,
|
||||||
} => {
|
} => {
|
||||||
|
assert_eq!(chat_id, expected_chat_id);
|
||||||
assert_eq!(msg_id, expected_msg_id);
|
assert_eq!(msg_id, expected_msg_id);
|
||||||
assert_eq!(contact_id, expected_contact_id);
|
assert_eq!(contact_id, expected_contact_id);
|
||||||
assert_eq!(reaction, Reaction::from(expected_reaction));
|
assert_eq!(reaction, Reaction::from(expected_reaction));
|
||||||
@@ -677,7 +681,14 @@ Here's my footer -- bob@example.net"
|
|||||||
assert_eq!(bob_reaction.as_str(), "👍");
|
assert_eq!(bob_reaction.as_str(), "👍");
|
||||||
expect_reactions_changed_event(&alice, chat_alice.id, alice_msg.sender_msg_id, *bob_id)
|
expect_reactions_changed_event(&alice, chat_alice.id, alice_msg.sender_msg_id, *bob_id)
|
||||||
.await?;
|
.await?;
|
||||||
expect_incoming_reactions_event(&alice, alice_msg.sender_msg_id, *bob_id, "👍").await?;
|
expect_incoming_reactions_event(
|
||||||
|
&alice,
|
||||||
|
chat_alice.id,
|
||||||
|
alice_msg.sender_msg_id,
|
||||||
|
*bob_id,
|
||||||
|
"👍",
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
expect_no_unwanted_events(&alice).await;
|
expect_no_unwanted_events(&alice).await;
|
||||||
|
|
||||||
// Alice reacts to own message.
|
// Alice reacts to own message.
|
||||||
@@ -720,7 +731,13 @@ Here's my footer -- bob@example.net"
|
|||||||
send_reaction(&bob, bob_msg1.id, "👍").await?;
|
send_reaction(&bob, bob_msg1.id, "👍").await?;
|
||||||
let bob_send_reaction = bob.pop_sent_msg().await;
|
let bob_send_reaction = bob.pop_sent_msg().await;
|
||||||
alice.recv_msg_trash(&bob_send_reaction).await;
|
alice.recv_msg_trash(&bob_send_reaction).await;
|
||||||
expect_incoming_reactions_event(&alice, alice_msg1.sender_msg_id, alice_bob_id, "👍")
|
expect_incoming_reactions_event(
|
||||||
|
&alice,
|
||||||
|
alice_chat.id,
|
||||||
|
alice_msg1.sender_msg_id,
|
||||||
|
alice_bob_id,
|
||||||
|
"👍",
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
expect_no_unwanted_events(&alice).await;
|
expect_no_unwanted_events(&alice).await;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user