feat: verify dm relays when open chat panel
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use anyhow::anyhow;
|
||||
use async_utility::tokio::sync::oneshot;
|
||||
use common::utils::{compare, room_hash, signer_public_key};
|
||||
use gpui::{App, AppContext, Context, Entity, Global};
|
||||
@@ -151,6 +152,21 @@ impl ChatRegistry {
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn new_room(&mut self, room: Room, cx: &mut Context<Self>) -> Result<(), anyhow::Error> {
|
||||
if !self
|
||||
.rooms
|
||||
.iter()
|
||||
.any(|current| compare(¤t.read(cx).pubkeys(), &room.pubkeys()))
|
||||
{
|
||||
self.rooms.insert(0, cx.new(|_| room));
|
||||
cx.notify();
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!("Room is existed"))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push_message(&mut self, event: Event, cx: &mut Context<Self>) {
|
||||
// Get all pubkeys from event's tags for comparision
|
||||
let mut pubkeys: Vec<_> = event.tags.public_keys().copied().collect();
|
||||
|
||||
Reference in New Issue
Block a user