feat(webapi): include cid in ServerEvent::Msg

This commit is contained in:
oxalica 2024-10-08 21:14:13 -04:00
parent 814fac1974
commit ff7fd9e4b2
6 changed files with 18 additions and 18 deletions

View file

@ -11,7 +11,7 @@ use anyhow::{bail, Context as _, Result};
use axum::extract::ws::{close_code, CloseFrame, Message, WebSocket};
use axum::extract::WebSocketUpgrade;
use axum::response::Response;
use blah_types::msg::{AuthPayload, SignedChatMsg};
use blah_types::msg::{AuthPayload, SignedChatMsgWithId};
use blah_types::server::{ClientEvent, ServerEvent};
use blah_types::Signed;
use futures_util::future::Either;
@ -58,7 +58,7 @@ pub struct State {
}
impl State {
pub fn on_room_msg(&self, msg: SignedChatMsg, room_members: Vec<i64>) {
pub fn on_room_msg(&self, msg: SignedChatMsgWithId, room_members: Vec<i64>) {
let listeners = self.user_listeners.lock();
let mut cnt = 0usize;
let msg = Arc::new(ServerEvent::Msg(msg));

View file

@ -13,7 +13,7 @@ use axum_extra::extract::WithRejection as R;
use blah_types::msg::{
ChatPayload, CreateGroup, CreatePeerChat, CreateRoomPayload, DeleteRoomPayload,
MemberPermission, RoomAdminOp, RoomAdminPayload, RoomAttrs, ServerPermission,
SignedChatMsgWithId,
SignedChatMsgWithId, WithMsgId,
};
use blah_types::server::{
ErrorResponseWithChallenge, RoomList, RoomMember, RoomMemberList, RoomMetadata, RoomMsgs,
@ -460,7 +460,7 @@ async fn post_room_msg(
})?;
// FIXME: Optimize this to not traverses over all members.
st.event.on_room_msg(chat, members);
st.event.on_room_msg(WithMsgId::new(cid, chat), members);
Ok(Json(cid))
}