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,6 +223,7 @@ 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) {
|
||||||
|
if !event_sent_from_us(&event, r.from_device()) {
|
||||||
let request = VerificationRequest::from_request(
|
let request = VerificationRequest::from_request(
|
||||||
self.verifications.clone(),
|
self.verifications.clone(),
|
||||||
self.account.clone(),
|
self.account.clone(),
|
||||||
|
@ -225,7 +234,15 @@ impl VerificationMachine {
|
||||||
r,
|
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