remove usages of &String
and &Owned[..]
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
2e83e56a07
commit
919735b4ce
7 changed files with 15 additions and 15 deletions
|
@ -8,7 +8,7 @@ use ruma::{
|
||||||
room::message::{Relation::Reply, RoomMessageEventContent},
|
room::message::{Relation::Reply, RoomMessageEventContent},
|
||||||
TimelineEventType,
|
TimelineEventType,
|
||||||
},
|
},
|
||||||
OwnedRoomId, OwnedUserId, ServerName, UserId,
|
OwnedRoomId, OwnedUserId, RoomId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
use tokio::sync::MutexGuard;
|
use tokio::sync::MutexGuard;
|
||||||
|
@ -125,7 +125,7 @@ async fn handle_event(event: AdminRoomEvent, admin_room: OwnedRoomId, server_use
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_response_error(
|
async fn handle_response_error(
|
||||||
e: &Error, admin_room: &OwnedRoomId, server_user: &UserId, state_lock: &MutexGuard<'_, ()>,
|
e: &Error, admin_room: &RoomId, server_user: &UserId, state_lock: &MutexGuard<'_, ()>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
error!("Failed to build and append admin room response PDU: \"{e}\"");
|
error!("Failed to build and append admin room response PDU: \"{e}\"");
|
||||||
let error_room_message = RoomMessageEventContent::text_plain(format!(
|
let error_room_message = RoomMessageEventContent::text_plain(format!(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
pub(crate) use conduit::utils::HtmlEscape;
|
pub(crate) use conduit::utils::HtmlEscape;
|
||||||
use ruma::OwnedRoomId;
|
use ruma::{OwnedRoomId, RoomId};
|
||||||
|
|
||||||
use crate::services;
|
use crate::services;
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ pub(crate) fn escape_html(s: &str) -> String {
|
||||||
.replace('>', ">")
|
.replace('>', ">")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_room_info(id: &OwnedRoomId) -> (OwnedRoomId, u64, String) {
|
pub(crate) fn get_room_info(id: &RoomId) -> (OwnedRoomId, u64, String) {
|
||||||
(
|
(
|
||||||
id.clone(),
|
id.into(),
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ruma::{
|
||||||
},
|
},
|
||||||
federation,
|
federation,
|
||||||
},
|
},
|
||||||
OwnedRoomAliasId, OwnedRoomId, OwnedServerName,
|
OwnedRoomAliasId, OwnedServerName, RoomAliasId, RoomId,
|
||||||
};
|
};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ pub async fn get_alias_helper(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn room_available_servers(
|
fn room_available_servers(
|
||||||
room_id: &OwnedRoomId, room_alias: &OwnedRoomAliasId, pre_servers: &Option<Vec<OwnedServerName>>,
|
room_id: &RoomId, room_alias: &RoomAliasId, pre_servers: &Option<Vec<OwnedServerName>>,
|
||||||
) -> Vec<OwnedServerName> {
|
) -> Vec<OwnedServerName> {
|
||||||
// find active servers in room state cache to suggest
|
// find active servers in room state cache to suggest
|
||||||
let mut servers: Vec<OwnedServerName> = services()
|
let mut servers: Vec<OwnedServerName> = services()
|
||||||
|
@ -260,7 +260,7 @@ fn room_available_servers(
|
||||||
servers
|
servers
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn alias_checks(room_alias: &OwnedRoomAliasId, appservice_info: &Option<RegistrationInfo>) -> Result<()> {
|
async fn alias_checks(room_alias: &RoomAliasId, appservice_info: &Option<RegistrationInfo>) -> Result<()> {
|
||||||
if !server_is_ours(room_alias.server_name()) {
|
if !server_is_ours(room_alias.server_name()) {
|
||||||
return Err(Error::BadRequest(ErrorKind::InvalidParam, "Alias is from another server."));
|
return Err(Error::BadRequest(ErrorKind::InvalidParam, "Alias is from another server."));
|
||||||
}
|
}
|
||||||
|
|
|
@ -886,7 +886,7 @@ fn default_power_levels_content(
|
||||||
|
|
||||||
/// if a room is being created with a room alias, run our checks
|
/// if a room is being created with a room alias, run our checks
|
||||||
async fn room_alias_check(
|
async fn room_alias_check(
|
||||||
room_alias_name: &String, appservice_info: &Option<RegistrationInfo>,
|
room_alias_name: &str, appservice_info: &Option<RegistrationInfo>,
|
||||||
) -> Result<OwnedRoomAliasId> {
|
) -> Result<OwnedRoomAliasId> {
|
||||||
// Basic checks on the room alias validity
|
// Basic checks on the room alias validity
|
||||||
if room_alias_name.contains(':') {
|
if room_alias_name.contains(':') {
|
||||||
|
@ -944,7 +944,7 @@ async fn room_alias_check(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// if a room is being created with a custom room ID, run our checks against it
|
/// if a room is being created with a custom room ID, run our checks against it
|
||||||
fn custom_room_id_check(custom_room_id: &String) -> Result<OwnedRoomId> {
|
fn custom_room_id_check(custom_room_id: &str) -> Result<OwnedRoomId> {
|
||||||
// apply forbidden room alias checks to custom room IDs too
|
// apply forbidden room alias checks to custom room IDs too
|
||||||
if services()
|
if services()
|
||||||
.globals
|
.globals
|
||||||
|
|
|
@ -492,7 +492,7 @@ async fn handle_left_room(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_presence_updates(
|
async fn process_presence_updates(
|
||||||
presence_updates: &mut HashMap<OwnedUserId, PresenceEvent>, since: u64, syncing_user: &OwnedUserId,
|
presence_updates: &mut HashMap<OwnedUserId, PresenceEvent>, since: u64, syncing_user: &UserId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
use crate::service::presence::Presence;
|
use crate::service::presence::Presence;
|
||||||
|
|
||||||
|
|
|
@ -111,9 +111,9 @@ impl Service {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn receive(&self, event: AdminRoomEvent, room: &OwnedRoomId, user: &UserId) -> Result<(), Error> {
|
async fn receive(&self, event: AdminRoomEvent, room: &RoomId, user: &UserId) -> Result<(), Error> {
|
||||||
if let Some(handle) = self.handle.lock().await.as_ref() {
|
if let Some(handle) = self.handle.lock().await.as_ref() {
|
||||||
handle(event, room.clone(), user.into()).await
|
handle(event, room.into(), user.into()).await
|
||||||
} else {
|
} else {
|
||||||
Err(Error::Err("Admin module is not loaded.".into()))
|
Err(Error::Err("Admin module is not loaded.".into()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,7 +406,7 @@ async fn send_events(dest: Destination, events: Vec<SendingEvent>) -> SendingRes
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(dest, events))]
|
#[tracing::instrument(skip(dest, events))]
|
||||||
async fn send_events_dest_appservice(dest: &Destination, id: &String, events: Vec<SendingEvent>) -> SendingResult {
|
async fn send_events_dest_appservice(dest: &Destination, id: &str, events: Vec<SendingEvent>) -> SendingResult {
|
||||||
let mut pdu_jsons = Vec::new();
|
let mut pdu_jsons = Vec::new();
|
||||||
|
|
||||||
for event in &events {
|
for event in &events {
|
||||||
|
@ -469,7 +469,7 @@ async fn send_events_dest_appservice(dest: &Destination, id: &String, events: Ve
|
||||||
|
|
||||||
#[tracing::instrument(skip(dest, events))]
|
#[tracing::instrument(skip(dest, events))]
|
||||||
async fn send_events_dest_push(
|
async fn send_events_dest_push(
|
||||||
dest: &Destination, userid: &OwnedUserId, pushkey: &String, events: Vec<SendingEvent>,
|
dest: &Destination, userid: &OwnedUserId, pushkey: &str, events: Vec<SendingEvent>,
|
||||||
) -> SendingResult {
|
) -> SendingResult {
|
||||||
let mut pdus = Vec::new();
|
let mut pdus = Vec::new();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue