Merge branch 'improvements' into 'next'
cross signing fixes See merge request famedly/conduit!532
This commit is contained in:
commit
3e518773e2
10 changed files with 115 additions and 64 deletions
|
@ -9,6 +9,7 @@ use lru_cache::LruCache;
|
|||
use ruma::{
|
||||
events::{
|
||||
room::{
|
||||
avatar::RoomAvatarEventContent,
|
||||
history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
|
||||
member::{MembershipState, RoomMemberEventContent},
|
||||
name::RoomNameEventContent,
|
||||
|
@ -283,6 +284,17 @@ impl Service {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_avatar(&self, room_id: &RoomId) -> Result<Option<RoomAvatarEventContent>> {
|
||||
services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.room_state_get(&room_id, &StateEventType::RoomAvatar, "")?
|
||||
.map_or(Ok(None), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map_err(|_| Error::bad_database("Invalid room avatar event in database."))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_member(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
|
|
@ -14,6 +14,7 @@ use ruma::{
|
|||
serde::Raw,
|
||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
|
||||
};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{services, Error, Result};
|
||||
|
||||
|
@ -88,8 +89,9 @@ impl Service {
|
|||
RoomAccountDataEventType::Tag,
|
||||
)?
|
||||
.map(|event| {
|
||||
serde_json::from_str(event.get()).map_err(|_| {
|
||||
Error::bad_database("Invalid account data event in db.")
|
||||
serde_json::from_str(event.get()).map_err(|e| {
|
||||
warn!("Invalid account data event in db: {e:?}");
|
||||
Error::BadDatabase("Invalid account data event in db.")
|
||||
})
|
||||
})
|
||||
{
|
||||
|
@ -113,8 +115,9 @@ impl Service {
|
|||
GlobalAccountDataEventType::Direct.to_string().into(),
|
||||
)?
|
||||
.map(|event| {
|
||||
serde_json::from_str::<DirectEvent>(event.get()).map_err(|_| {
|
||||
Error::bad_database("Invalid account data event in db.")
|
||||
serde_json::from_str::<DirectEvent>(event.get()).map_err(|e| {
|
||||
warn!("Invalid account data event in db: {e:?}");
|
||||
Error::BadDatabase("Invalid account data event in db.")
|
||||
})
|
||||
})
|
||||
{
|
||||
|
@ -155,8 +158,10 @@ impl Service {
|
|||
.into(),
|
||||
)?
|
||||
.map(|event| {
|
||||
serde_json::from_str::<IgnoredUserListEvent>(event.get())
|
||||
.map_err(|_| Error::bad_database("Invalid account data event in db."))
|
||||
serde_json::from_str::<IgnoredUserListEvent>(event.get()).map_err(|e| {
|
||||
warn!("Invalid account data event in db: {e:?}");
|
||||
Error::BadDatabase("Invalid account data event in db.")
|
||||
})
|
||||
})
|
||||
.transpose()?
|
||||
.map_or(false, |ignored| {
|
||||
|
|
|
@ -111,6 +111,7 @@ pub trait Data: Send + Sync {
|
|||
master_key: &Raw<CrossSigningKey>,
|
||||
self_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
user_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
notify: bool,
|
||||
) -> Result<()>;
|
||||
|
||||
fn sign_key(
|
||||
|
|
|
@ -66,7 +66,7 @@ impl Service {
|
|||
return BTreeMap::new();
|
||||
};
|
||||
|
||||
let cache = &mut self.connections.lock().unwrap();
|
||||
let mut cache = self.connections.lock().unwrap();
|
||||
let cached = Arc::clone(
|
||||
cache
|
||||
.entry((user_id, device_id, conn_id))
|
||||
|
@ -185,7 +185,7 @@ impl Service {
|
|||
conn_id: String,
|
||||
subscriptions: BTreeMap<OwnedRoomId, sync_events::v4::RoomSubscription>,
|
||||
) {
|
||||
let cache = &mut self.connections.lock().unwrap();
|
||||
let mut cache = self.connections.lock().unwrap();
|
||||
let cached = Arc::clone(
|
||||
cache
|
||||
.entry((user_id, device_id, conn_id))
|
||||
|
@ -212,7 +212,7 @@ impl Service {
|
|||
list_id: String,
|
||||
new_cached_rooms: BTreeMap<OwnedRoomId, bool>,
|
||||
) {
|
||||
let cache = &mut self.connections.lock().unwrap();
|
||||
let mut cache = self.connections.lock().unwrap();
|
||||
let cached = Arc::clone(
|
||||
cache
|
||||
.entry((user_id, device_id, conn_id))
|
||||
|
@ -398,9 +398,15 @@ impl Service {
|
|||
master_key: &Raw<CrossSigningKey>,
|
||||
self_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
user_signing_key: &Option<Raw<CrossSigningKey>>,
|
||||
notify: bool,
|
||||
) -> Result<()> {
|
||||
self.db
|
||||
.add_cross_signing_keys(user_id, master_key, self_signing_key, user_signing_key)
|
||||
self.db.add_cross_signing_keys(
|
||||
user_id,
|
||||
master_key,
|
||||
self_signing_key,
|
||||
user_signing_key,
|
||||
notify,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn sign_key(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue