-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
378 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod image_c2c_download; | ||
pub mod image_group_download; | ||
pub mod multi_msg_download; | ||
pub mod push_msg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use crate::core::event::prelude::*; | ||
use crate::core::protos::message::{ | ||
LongMsgResult, LongMsgSettings, LongMsgUid, RecvLongMsgInfo, RecvLongMsgReq, RecvLongMsgResp, | ||
}; | ||
use crate::message::chain::MessageChain; | ||
use crate::message::packer::MessagePacker; | ||
use crate::utility::compress::gzip; | ||
use mania_macros::{commend, ServerEvent}; | ||
|
||
#[commend("trpc.group.long_msg_interface.MsgService.SsoRecvLongMsg")] | ||
#[derive(Debug, ServerEvent, Default)] | ||
pub struct MultiMsgDownloadEvent { | ||
pub uid: Option<String>, | ||
pub res_id: Option<String>, | ||
pub chains: Option<Vec<MessageChain>>, | ||
} | ||
|
||
impl ClientEvent for MultiMsgDownloadEvent { | ||
fn build(&self, _: &Context) -> BinaryPacket { | ||
let packet = RecvLongMsgReq { | ||
info: Some(RecvLongMsgInfo { | ||
uid: Some(LongMsgUid { | ||
uid: self.uid.clone(), | ||
}), | ||
res_id: self.res_id.clone(), | ||
acquire: true, | ||
}), | ||
settings: Some(LongMsgSettings { | ||
field1: 2, | ||
field2: 0, | ||
field3: 0, | ||
field4: 0, | ||
}), | ||
}; | ||
BinaryPacket(packet.encode_to_vec().into()) | ||
} | ||
|
||
fn parse(packet: Bytes, _: &Context) -> Result<Box<dyn ServerEvent>, EventError> { | ||
let packet = RecvLongMsgResp::decode(packet)?; | ||
let inflate = gzip::decompress(&packet.result.expect("missing RecvLongMsgInfo").payload) | ||
.ok_or(EventError::OtherError( | ||
"Failed to decompress long message".to_string(), | ||
))?; | ||
let result = LongMsgResult::decode(Bytes::from(inflate))?; | ||
let main = result | ||
.action | ||
.into_iter() | ||
.find(|a| a.action_command == "MultiMsg") | ||
.ok_or(EventError::OtherError( | ||
"Failed to find MultiMsg command".to_string(), | ||
))?; | ||
let chains = main | ||
.action_data | ||
.ok_or(EventError::OtherError( | ||
"Failed to find action_data".to_string(), | ||
))? | ||
.msg_body | ||
.into_iter() | ||
.map(MessagePacker::parse_fake_chain) | ||
.collect::<Result<Vec<MessageChain>, String>>() | ||
.map_err(EventError::OtherError)?; | ||
Ok(Box::new(dda!(MultiMsgDownloadEvent { | ||
chains: Some(chains), | ||
}))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.