move presence up two levels out of rooms.edus and rooms.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-03-31 17:35:13 -07:00 committed by June
parent 9790477b0e
commit 0ba8d1318d
15 changed files with 13 additions and 41 deletions

View file

@ -19,7 +19,7 @@ pub async fn set_presence_route(body: Ruma<set_presence::v3::Request>) -> Result
for room_id in services().rooms.state_cache.rooms_joined(sender_user) {
let room_id = room_id?;
services().rooms.edus.presence.set_presence(
services().presence.set_presence(
&room_id,
sender_user,
body.presence.clone(),
@ -54,8 +54,6 @@ pub async fn get_presence_route(body: Ruma<get_presence::v3::Request>) -> Result
let room_id = room_id?;
if let Some(presence) = services()
.rooms
.edus
.presence
.get_presence(&room_id, sender_user)?
{

View file

@ -88,8 +88,6 @@ pub async fn set_displayname_route(
if services().globals.allow_local_presence() {
// Presence update
services()
.rooms
.edus
.presence
.ping_presence(sender_user, PresenceState::Online)?;
}
@ -229,8 +227,6 @@ pub async fn set_avatar_url_route(body: Ruma<set_avatar_url::v3::Request>) -> Re
if services().globals.allow_local_presence() {
// Presence update
services()
.rooms
.edus
.presence
.ping_presence(sender_user, PresenceState::Online)?;
}

View file

@ -173,8 +173,6 @@ async fn sync_helper(
// Presence update
if services().globals.allow_local_presence() {
services()
.rooms
.edus
.presence
.ping_presence(&sender_user, body.set_presence)?;
}
@ -531,8 +529,6 @@ async fn process_room_presence_updates(
) -> Result<()> {
// Take presence updates from this room
for (user_id, _, presence_event) in services()
.rooms
.edus
.presence
.presence_since(room_id, since)
{

View file

@ -339,7 +339,7 @@ pub async fn send_transaction_message_route(
for update in presence.push {
for room_id in services().rooms.state_cache.rooms_joined(&update.user_id) {
services().rooms.edus.presence.set_presence(
services().presence.set_presence(
&room_id?,
&update.user_id,
update.presence.clone(),

View file

@ -5,6 +5,7 @@ mod globals;
mod key_backups;
mod media;
//mod pdu;
mod presence;
mod pusher;
mod rooms;
mod sending;

View file

@ -5,13 +5,13 @@ use tracing::error;
use crate::{
database::KeyValueDatabase,
service::{self, rooms::edus::presence::Presence},
service::{self, presence::Presence},
services,
utils::{self, user_id_from_bytes},
Error, Result,
};
impl service::rooms::edus::presence::Data for KeyValueDatabase {
impl service::presence::Data for KeyValueDatabase {
fn get_presence(&self, room_id: &RoomId, user_id: &UserId) -> Result<Option<PresenceEvent>> {
let key = presence_key(room_id, user_id);

View file

@ -1,5 +0,0 @@
mod presence;
use crate::{database::KeyValueDatabase, service};
impl service::rooms::edus::Data for KeyValueDatabase {}

View file

@ -1,7 +1,6 @@
mod alias;
mod auth_chain;
mod directory;
mod edus;
mod lazy_load;
mod metadata;
mod outlier;

View file

@ -35,7 +35,7 @@ use tokio::{
use tracing::{debug, error, info, warn};
use crate::{
service::rooms::{edus::presence::presence_handler, timeline::PduCount},
service::{presence::presence_handler, rooms::timeline::PduCount},
services, utils, Config, Error, PduEvent, Result, Services, SERVICES,
};

View file

@ -15,6 +15,7 @@ pub(crate) mod globals;
pub(crate) mod key_backups;
pub(crate) mod media;
pub(crate) mod pdu;
pub(crate) mod presence;
pub(crate) mod pusher;
pub(crate) mod rooms;
pub(crate) mod sending;
@ -30,6 +31,7 @@ pub struct Services<'a> {
pub uiaa: uiaa::Service,
pub users: users::Service,
pub account_data: account_data::Service,
pub presence: presence::Service,
pub admin: Arc<admin::Service>,
pub globals: globals::Service<'a>,
pub key_backups: key_backups::Service,
@ -46,6 +48,7 @@ impl Services<'_> {
+ uiaa::Data
+ users::Data
+ account_data::Data
+ presence::Data
+ globals::Data
+ key_backups::Data
+ media::Data
@ -69,11 +72,6 @@ impl Services<'_> {
directory: rooms::directory::Service {
db,
},
edus: rooms::edus::Service {
presence: rooms::edus::presence::Service {
db,
},
},
event_handler: rooms::event_handler::Service,
lazy_loading: rooms::lazy_loading::Service {
db,
@ -152,6 +150,9 @@ impl Services<'_> {
account_data: account_data::Service {
db,
},
presence: presence::Service {
db,
},
admin: admin::Service::build(),
key_backups: key_backups::Service {
db,

View file

@ -144,8 +144,6 @@ fn process_presence_timer(user_id: &OwnedUserId) -> Result<()> {
for room_id in services().rooms.state_cache.rooms_joined(user_id) {
let presence_event = services()
.rooms
.edus
.presence
.get_presence(&room_id?, user_id)?;
@ -168,7 +166,7 @@ fn process_presence_timer(user_id: &OwnedUserId) -> Result<()> {
if let Some(new_state) = new_state {
for room_id in services().rooms.state_cache.rooms_joined(user_id) {
services().rooms.edus.presence.set_presence(
services().presence.set_presence(
&room_id?,
user_id,
new_state.clone(),

View file

@ -1,7 +0,0 @@
pub mod presence;
pub trait Data: presence::Data + 'static {}
pub struct Service {
pub presence: presence::Service,
}

View file

@ -1,7 +1,6 @@
pub mod alias;
pub mod auth_chain;
pub mod directory;
pub mod edus;
pub mod event_handler;
pub mod lazy_loading;
pub mod metadata;
@ -24,7 +23,6 @@ pub trait Data:
alias::Data
+ auth_chain::Data
+ directory::Data
+ edus::Data
+ lazy_loading::Data
+ metadata::Data
+ outlier::Data
@ -46,7 +44,6 @@ pub struct Service {
pub alias: alias::Service,
pub auth_chain: auth_chain::Service,
pub directory: directory::Service,
pub edus: edus::Service,
pub event_handler: event_handler::Service,
pub lazy_loading: lazy_loading::Service,
pub metadata: metadata::Service,

View file

@ -484,8 +484,6 @@ pub fn select_edus_presence(
// Look for presence updates in this room
let mut presence_updates = Vec::new();
for (user_id, count, presence_event) in services()
.rooms
.edus
.presence
.presence_since(room_id, since)
{