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:
trisua 2025-04-29 16:53:34 -04:00
parent c1c8cdbfcd
commit 0304461389
20 changed files with 241 additions and 160 deletions

View file

@ -528,7 +528,7 @@ macro_rules! auto_method {
if !user.permissions.check(FinePermission::$permission) {
return Err(Error::NotAllowed);
} else {
self.create_audit_log_entry(crate::model::moderation::AuditLogEntry::new(
self.create_audit_log_entry($crate::model::moderation::AuditLogEntry::new(
user.id,
format!("invoked `{}` with x value `{x}`", stringify!($name)),
))
@ -607,7 +607,7 @@ macro_rules! auto_method {
if !user.permissions.check(FinePermission::$permission) {
return Err(Error::NotAllowed);
} else {
self.create_audit_log_entry(crate::model::moderation::AuditLogEntry::new(
self.create_audit_log_entry($crate::model::moderation::AuditLogEntry::new(
user.id,
format!("invoked `{}` with x value `{x:?}`", stringify!($name)),
))

View file

@ -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(),

View file

@ -121,7 +121,7 @@ impl DataManager {
pub async fn fill_posts(
&self,
posts: Vec<Post>,
ignore_users: &Vec<usize>,
ignore_users: &[usize],
) -> Result<Vec<(Post, User, Option<(User, Post)>, Option<(Question, User)>)>> {
let mut out: Vec<(Post, User, Option<(User, Post)>, Option<(Question, User)>)> = Vec::new();
@ -160,7 +160,7 @@ impl DataManager {
&self,
posts: Vec<Post>,
user_id: usize,
ignore_users: &Vec<usize>,
ignore_users: &[usize],
) -> Result<
Vec<(
Post,

View file

@ -49,7 +49,7 @@ impl DataManager {
pub async fn fill_questions(
&self,
questions: Vec<Question>,
ignore_users: &Vec<usize>,
ignore_users: &[usize],
) -> Result<Vec<(Question, User)>> {
let mut out: Vec<(Question, User)> = Vec::new();