add: connect to socket by community
direct messages/groups connect by channel id, everything else should connect by channel with the "is_channel" header set to true
This commit is contained in:
parent
c1c8cdbfcd
commit
0304461389
20 changed files with 241 additions and 160 deletions
|
@ -49,7 +49,7 @@ impl DataManager {
|
|||
pub async fn fill_messages(
|
||||
&self,
|
||||
messages: Vec<Message>,
|
||||
ignore_users: &Vec<usize>,
|
||||
ignore_users: &[usize],
|
||||
) -> Result<Vec<(Message, User)>> {
|
||||
let mut out: Vec<(Message, User)> = Vec::new();
|
||||
|
||||
|
@ -158,10 +158,16 @@ impl DataManager {
|
|||
let mut con = self.2.get_con().await;
|
||||
|
||||
if let Err(e) = con.publish::<usize, String, ()>(
|
||||
data.channel,
|
||||
if channel.community != 0 {
|
||||
// broadcast to community ws
|
||||
channel.community
|
||||
} else {
|
||||
// broadcast to channel ws
|
||||
channel.id
|
||||
},
|
||||
serde_json::to_string(&SocketMessage {
|
||||
method: SocketMethod::Message,
|
||||
data: serde_json::to_string(&data).unwrap(),
|
||||
data: serde_json::to_string(&(data.channel.to_string(), data)).unwrap(),
|
||||
})
|
||||
.unwrap(),
|
||||
) {
|
||||
|
@ -211,7 +217,13 @@ impl DataManager {
|
|||
let mut con = self.2.get_con().await;
|
||||
|
||||
if let Err(e) = con.publish::<usize, String, ()>(
|
||||
message.channel,
|
||||
if channel.community != 0 {
|
||||
// broadcast to community ws
|
||||
channel.community
|
||||
} else {
|
||||
// broadcast to channel ws
|
||||
channel.id
|
||||
},
|
||||
serde_json::to_string(&SocketMessage {
|
||||
method: SocketMethod::Delete,
|
||||
data: serde_json::to_string(&DeleteMessageEvent { id: id.to_string() }).unwrap(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue