Bump ruma

This commit is contained in:
Timo Kösters 2022-10-09 17:25:06 +02:00 committed by Nyaaori
parent 275c6b447d
commit 6b131202b9
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
68 changed files with 446 additions and 347 deletions

View file

@ -1,4 +1,4 @@
use ruma::{api::client::error::ErrorKind, RoomAliasId, RoomId};
use ruma::{api::client::error::ErrorKind, OwnedRoomAliasId, OwnedRoomId, RoomAliasId, RoomId};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -31,7 +31,7 @@ impl service::rooms::alias::Data for KeyValueDatabase {
Ok(())
}
fn resolve_local_alias(&self, alias: &RoomAliasId) -> Result<Option<Box<RoomId>>> {
fn resolve_local_alias(&self, alias: &RoomAliasId) -> Result<Option<OwnedRoomId>> {
self.alias_roomid
.get(alias.alias().as_bytes())?
.map(|bytes| {
@ -46,7 +46,7 @@ impl service::rooms::alias::Data for KeyValueDatabase {
fn local_aliases_for_room<'a>(
&'a self,
room_id: &RoomId,
) -> Box<dyn Iterator<Item = Result<Box<RoomAliasId>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedRoomAliasId>> + 'a> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);

View file

@ -1,4 +1,4 @@
use ruma::RoomId;
use ruma::{OwnedRoomId, RoomId};
use crate::{database::KeyValueDatabase, service, utils, Error, Result};
@ -15,7 +15,7 @@ impl service::rooms::directory::Data for KeyValueDatabase {
Ok(self.publicroomids.get(room_id.as_bytes())?.is_some())
}
fn public_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a> {
fn public_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
Box::new(self.publicroomids.iter().map(|(bytes, _)| {
RoomId::parse(
utils::string_from_bytes(&bytes).map_err(|_| {

View file

@ -1,6 +1,8 @@
use std::collections::HashMap;
use ruma::{events::presence::PresenceEvent, presence::PresenceState, RoomId, UInt, UserId};
use ruma::{
events::presence::PresenceEvent, presence::PresenceState, OwnedUserId, RoomId, UInt, UserId,
};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -76,7 +78,7 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase {
&self,
room_id: &RoomId,
since: u64,
) -> Result<HashMap<Box<UserId>, PresenceEvent>> {
) -> Result<HashMap<OwnedUserId, PresenceEvent>> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);

View file

@ -1,7 +1,7 @@
use std::mem;
use ruma::{
events::receipt::ReceiptEvent, serde::Raw, signatures::CanonicalJsonObject, RoomId, UserId,
events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject, OwnedUserId, RoomId, UserId,
};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -55,7 +55,7 @@ impl service::rooms::edus::read_receipt::Data for KeyValueDatabase {
) -> Box<
dyn Iterator<
Item = Result<(
Box<UserId>,
OwnedUserId,
u64,
Raw<ruma::events::AnySyncEphemeralRoomEvent>,
)>,

View file

@ -1,6 +1,6 @@
use std::collections::HashSet;
use ruma::{RoomId, UserId};
use ruma::{OwnedUserId, RoomId, UserId};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -66,7 +66,7 @@ impl service::rooms::edus::typing::Data for KeyValueDatabase {
.unwrap_or(0))
}
fn typings_all(&self, room_id: &RoomId) -> Result<HashSet<Box<UserId>>> {
fn typings_all(&self, room_id: &RoomId) -> Result<HashSet<OwnedUserId>> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);

View file

@ -1,4 +1,4 @@
use ruma::RoomId;
use ruma::{OwnedRoomId, RoomId};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -18,7 +18,7 @@ impl service::rooms::metadata::Data for KeyValueDatabase {
.is_some())
}
fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a> {
fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
Box::new(self.roomid_shortroomid.iter().map(|(bytes, _)| {
RoomId::parse(
utils::string_from_bytes(&bytes).map_err(|_| {

View file

@ -1,4 +1,4 @@
use ruma::{signatures::CanonicalJsonObject, EventId};
use ruma::{CanonicalJsonObject, EventId};
use crate::{database::KeyValueDatabase, service, Error, PduEvent, Result};

View file

@ -1,4 +1,4 @@
use ruma::{EventId, RoomId};
use ruma::{EventId, OwnedEventId, RoomId};
use std::collections::HashSet;
use std::sync::Arc;
@ -52,7 +52,7 @@ impl service::rooms::state::Data for KeyValueDatabase {
fn set_forward_extremities<'a>(
&self,
room_id: &RoomId,
event_ids: Vec<Box<EventId>>,
event_ids: Vec<OwnedEventId>,
_mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room state mutex
) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec();

View file

@ -4,7 +4,7 @@ use regex::Regex;
use ruma::{
events::{AnyStrippedStateEvent, AnySyncStateEvent},
serde::Raw,
RoomId, ServerName, UserId,
OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -163,7 +163,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
}
#[tracing::instrument(skip(self, room_id))]
fn get_our_real_users(&self, room_id: &RoomId) -> Result<Arc<HashSet<Box<UserId>>>> {
fn get_our_real_users(&self, room_id: &RoomId) -> Result<Arc<HashSet<OwnedUserId>>> {
let maybe = self
.our_real_users_cache
.read()
@ -262,7 +262,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn room_servers<'a>(
&'a self,
room_id: &RoomId,
) -> Box<dyn Iterator<Item = Result<Box<ServerName>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedServerName>> + 'a> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);
@ -295,7 +295,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn server_rooms<'a>(
&'a self,
server: &ServerName,
) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
let mut prefix = server.as_bytes().to_vec();
prefix.push(0xff);
@ -317,7 +317,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn room_members<'a>(
&'a self,
room_id: &RoomId,
) -> Box<dyn Iterator<Item = Result<Box<UserId>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedUserId>> + 'a> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);
@ -363,7 +363,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn room_useroncejoined<'a>(
&'a self,
room_id: &RoomId,
) -> Box<dyn Iterator<Item = Result<Box<UserId>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedUserId>> + 'a> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);
@ -393,7 +393,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn room_members_invited<'a>(
&'a self,
room_id: &RoomId,
) -> Box<dyn Iterator<Item = Result<Box<UserId>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedUserId>> + 'a> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);
@ -451,7 +451,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn rooms_joined<'a>(
&'a self,
user_id: &UserId,
) -> Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a> {
) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
Box::new(
self.userroomid_joined
.scan_prefix(user_id.as_bytes().to_vec())
@ -476,7 +476,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn rooms_invited<'a>(
&'a self,
user_id: &UserId,
) -> Box<dyn Iterator<Item = Result<(Box<RoomId>, Vec<Raw<AnyStrippedStateEvent>>)>> + 'a> {
) -> Box<dyn Iterator<Item = Result<(OwnedRoomId, Vec<Raw<AnyStrippedStateEvent>>)>> + 'a> {
let mut prefix = user_id.as_bytes().to_vec();
prefix.push(0xff);
@ -554,7 +554,7 @@ impl service::rooms::state_cache::Data for KeyValueDatabase {
fn rooms_left<'a>(
&'a self,
user_id: &UserId,
) -> Box<dyn Iterator<Item = Result<(Box<RoomId>, Vec<Raw<AnySyncStateEvent>>)>> + 'a> {
) -> Box<dyn Iterator<Item = Result<(OwnedRoomId, Vec<Raw<AnySyncStateEvent>>)>> + 'a> {
let mut prefix = user_id.as_bytes().to_vec();
prefix.push(0xff);

View file

@ -1,7 +1,7 @@
use std::{collections::hash_map, mem::size_of, sync::Arc};
use ruma::{
api::client::error::ErrorKind, signatures::CanonicalJsonObject, EventId, RoomId, UserId,
api::client::error::ErrorKind, CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId,
};
use tracing::error;
@ -344,8 +344,8 @@ impl service::rooms::timeline::Data for KeyValueDatabase {
fn increment_notification_counts(
&self,
room_id: &RoomId,
notifies: Vec<Box<UserId>>,
highlights: Vec<Box<UserId>>,
notifies: Vec<OwnedUserId>,
highlights: Vec<OwnedUserId>,
) -> Result<()> {
let mut notifies_batch = Vec::new();
let mut highlights_batch = Vec::new();

View file

@ -1,4 +1,4 @@
use ruma::{RoomId, UserId};
use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId};
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
@ -85,8 +85,8 @@ impl service::rooms::user::Data for KeyValueDatabase {
fn get_shared_rooms<'a>(
&'a self,
users: Vec<Box<UserId>>,
) -> Result<Box<dyn Iterator<Item = Result<Box<RoomId>>> + 'a>> {
users: Vec<OwnedUserId>,
) -> Result<Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a>> {
let iterators = users.into_iter().map(move |user_id| {
let mut prefix = user_id.as_bytes().to_vec();
prefix.push(0xff);
@ -110,7 +110,7 @@ impl service::rooms::user::Data for KeyValueDatabase {
});
// We use the default compare function because keys are sorted correctly (not reversed)
Ok(Box::new(Box::new(
Ok(Box::new(
utils::common_elements(iterators, Ord::cmp)
.expect("users is not empty")
.map(|bytes| {
@ -119,6 +119,6 @@ impl service::rooms::user::Data for KeyValueDatabase {
})?)
.map_err(|_| Error::bad_database("Invalid RoomId in userroomid_joined."))
}),
)))
))
}
}