crypto: Ignore verification requests that are sent by us
parent
cc0388929a
commit
073b91fa62
|
@ -64,6 +64,10 @@ impl AnyEvent<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_room_event(&self) -> bool {
|
||||||
|
matches!(self, AnyEvent::Room(_))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn verification_content(&self) -> Option<AnyVerificationContent> {
|
pub fn verification_content(&self) -> Option<AnyVerificationContent> {
|
||||||
match self {
|
match self {
|
||||||
AnyEvent::Room(e) => match e {
|
AnyEvent::Room(e) => match e {
|
||||||
|
|
|
@ -204,6 +204,14 @@ impl VerificationMachine {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let event_sent_from_us = |event: &AnyEvent<'_>, from_device: &DeviceId| {
|
||||||
|
if event.sender() == self.account.user_id() {
|
||||||
|
from_device == self.account.device_id() || event.is_room_event()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(content) = event.verification_content() {
|
if let Some(content) = event.verification_content() {
|
||||||
match &content {
|
match &content {
|
||||||
AnyVerificationContent::Request(r) => {
|
AnyVerificationContent::Request(r) => {
|
||||||
|
@ -215,17 +223,26 @@ impl VerificationMachine {
|
||||||
|
|
||||||
if let Some(timestamp) = event.timestamp() {
|
if let Some(timestamp) = event.timestamp() {
|
||||||
if Self::is_timestamp_valid(timestamp) {
|
if Self::is_timestamp_valid(timestamp) {
|
||||||
let request = VerificationRequest::from_request(
|
if !event_sent_from_us(&event, r.from_device()) {
|
||||||
self.verifications.clone(),
|
let request = VerificationRequest::from_request(
|
||||||
self.account.clone(),
|
self.verifications.clone(),
|
||||||
self.private_identity.lock().await.clone(),
|
self.account.clone(),
|
||||||
self.store.clone(),
|
self.private_identity.lock().await.clone(),
|
||||||
event.sender(),
|
self.store.clone(),
|
||||||
flow_id,
|
event.sender(),
|
||||||
r,
|
flow_id,
|
||||||
);
|
r,
|
||||||
|
);
|
||||||
|
|
||||||
self.requests.insert(request.flow_id().as_str().to_owned(), request);
|
self.requests
|
||||||
|
.insert(request.flow_id().as_str().to_owned(), request);
|
||||||
|
} else {
|
||||||
|
trace!(
|
||||||
|
sender = event.sender().as_str(),
|
||||||
|
from_device = r.from_device().as_str(),
|
||||||
|
"The received verification request was sent by us, ignoring it",
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
trace!(
|
trace!(
|
||||||
sender = event.sender().as_str(),
|
sender = event.sender().as_str(),
|
||||||
|
|
Loading…
Reference in New Issue