mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 00:31:09 +00:00
fix(event): consistently use i64 for uid
This commit is contained in:
parent
a7f31e5fad
commit
4bca196df3
2 changed files with 4 additions and 6 deletions
|
@ -63,7 +63,7 @@ fn de_duration_sec<'de, D: de::Deserializer<'de>>(de: D) -> Result<Duration, D::
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub user_listeners: Mutex<HashMap<u64, UserEventSender>>,
|
pub user_listeners: Mutex<HashMap<i64, UserEventSender>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -103,7 +103,7 @@ type UserEventSender = broadcast::Sender<Arc<SignedChatMsg>>;
|
||||||
struct UserEventReceiver {
|
struct UserEventReceiver {
|
||||||
rx: BroadcastStream<Arc<SignedChatMsg>>,
|
rx: BroadcastStream<Arc<SignedChatMsg>>,
|
||||||
st: Arc<AppState>,
|
st: Arc<AppState>,
|
||||||
uid: u64,
|
uid: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for UserEventReceiver {
|
impl Drop for UserEventReceiver {
|
||||||
|
@ -147,8 +147,7 @@ pub async fn handle_ws(st: Arc<AppState>, ws: &mut WebSocket) -> Result<Infallib
|
||||||
.db
|
.db
|
||||||
.with_read(|txn| txn.get_user(&auth.signee.user))
|
.with_read(|txn| txn.get_user(&auth.signee.user))
|
||||||
.map_err(|err| anyhow!("{}", err.message))?;
|
.map_err(|err| anyhow!("{}", err.message))?;
|
||||||
// FIXME: Consistency of id's sign.
|
uid
|
||||||
uid as u64
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::debug!(%uid, "user connected");
|
tracing::debug!(%uid, "user connected");
|
||||||
|
|
|
@ -583,8 +583,7 @@ async fn room_msg_post(
|
||||||
let listeners = st.event.user_listeners.lock();
|
let listeners = st.event.user_listeners.lock();
|
||||||
let mut cnt = 0usize;
|
let mut cnt = 0usize;
|
||||||
for uid in members {
|
for uid in members {
|
||||||
// FIXME: u64 vs i64.
|
if let Some(tx) = listeners.get(&uid) {
|
||||||
if let Some(tx) = listeners.get(&(uid as u64)) {
|
|
||||||
if tx.send(chat.clone()).is_ok() {
|
if tx.send(chat.clone()).is_ok() {
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue