|
@@ -36,11 +36,12 @@ impl Inv {
|
|
|
#[derive(SerialDecodable, SerialEncodable, Clone, Debug)]
|
|
#[derive(SerialDecodable, SerialEncodable, Clone, Debug)]
|
|
|
struct GetData {
|
|
struct GetData {
|
|
|
invs: Vec<InvObject>,
|
|
invs: Vec<InvObject>,
|
|
|
|
|
+ term: Option<u64>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl GetData {
|
|
impl GetData {
|
|
|
- fn new(invs: Vec<InvObject>) -> Self {
|
|
|
|
|
- Self { invs }
|
|
|
|
|
|
|
+ fn new(invs: Vec<InvObject>, term: Option<u64>) -> Self {
|
|
|
|
|
+ Self { invs, term }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -118,7 +119,7 @@ impl ProtocolPrivmsg {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if !inv_requested.is_empty() {
|
|
if !inv_requested.is_empty() {
|
|
|
- self.channel.send(GetData::new(inv_requested)).await?;
|
|
|
|
|
|
|
+ self.channel.send(GetData::new(inv_requested, None)).await?;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
self.update_unread_msgs().await?;
|
|
self.update_unread_msgs().await?;
|
|
@@ -160,12 +161,15 @@ impl ProtocolPrivmsg {
|
|
|
self.update_unread_msgs().await?;
|
|
self.update_unread_msgs().await?;
|
|
|
|
|
|
|
|
match self.buffers.privmsgs.last_term().await.cmp(&last_term) {
|
|
match self.buffers.privmsgs.last_term().await.cmp(&last_term) {
|
|
|
- Ordering::Less => {
|
|
|
|
|
|
|
+ Ordering::Greater => {
|
|
|
for msg in self.buffers.privmsgs.fetch_msgs(last_term).await {
|
|
for msg in self.buffers.privmsgs.fetch_msgs(last_term).await {
|
|
|
self.channel.send(msg).await?;
|
|
self.channel.send(msg).await?;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- Ordering::Greater | Ordering::Equal => continue,
|
|
|
|
|
|
|
+ Ordering::Less => {
|
|
|
|
|
+ self.channel.send(GetData::new(vec![], Some(last_term))).await?;
|
|
|
|
|
+ }
|
|
|
|
|
+ Ordering::Equal => continue,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -181,6 +185,12 @@ impl ProtocolPrivmsg {
|
|
|
self.channel.send(msg.clone()).await?;
|
|
self.channel.send(msg.clone()).await?;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if let Some(term) = getdata.term {
|
|
|
|
|
+ for msg in self.buffers.privmsgs.fetch_msgs(term).await {
|
|
|
|
|
+ self.channel.send(msg).await?;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|