1
0
Fork 0
mirror of https://forgejo.ellis.link/continuwuation/continuwuity.git synced 2025-09-12 17:20:57 +00:00
continuwuity/src/service/rooms/short/mod.rs

64 lines
1.6 KiB
Rust
Raw Normal View History

mod data;
use std::sync::Arc;
pub use data::Data;
2022-09-07 13:25:51 +02:00
use ruma::{EventId, events::StateEventType, RoomId};
2022-09-07 13:25:51 +02:00
use crate::{Result, Error, utils, services};
2022-10-05 12:45:54 +02:00
pub struct Service {
2022-10-05 18:36:12 +02:00
db: Arc<dyn Data>,
}
2022-10-05 12:45:54 +02:00
impl Service {
pub fn get_or_create_shorteventid(
&self,
event_id: &EventId,
) -> Result<u64> {
2022-10-05 18:36:12 +02:00
self.db.get_or_create_shorteventid(event_id)
}
2021-08-12 23:04:00 +02:00
pub fn get_shortstatekey(
&self,
2022-04-06 21:31:29 +02:00
event_type: &StateEventType,
2021-08-12 23:04:00 +02:00
state_key: &str,
) -> Result<Option<u64>> {
2022-10-05 18:36:12 +02:00
self.db.get_shortstatekey(event_type, state_key)
2021-08-12 23:04:00 +02:00
}
pub fn get_or_create_shortstatekey(
&self,
2022-04-06 21:31:29 +02:00
event_type: &StateEventType,
2021-08-12 23:04:00 +02:00
state_key: &str,
) -> Result<u64> {
2022-10-05 18:36:12 +02:00
self.db.get_or_create_shortstatekey(event_type, state_key)
2021-08-12 23:04:00 +02:00
}
pub fn get_eventid_from_short(&self, shorteventid: u64) -> Result<Arc<EventId>> {
2022-10-05 18:36:12 +02:00
self.db.get_eventid_from_short(shorteventid)
}
2022-04-06 21:31:29 +02:00
pub fn get_statekey_from_short(&self, shortstatekey: u64) -> Result<(StateEventType, String)> {
2022-10-05 18:36:12 +02:00
self.db.get_statekey_from_short(shortstatekey)
}
2022-06-19 22:56:14 +02:00
/// Returns (shortstatehash, already_existed)
2022-10-05 18:36:12 +02:00
pub fn get_or_create_shortstatehash(
2021-07-15 19:54:04 +02:00
&self,
2022-09-07 13:25:51 +02:00
state_hash: &[u8],
2022-06-19 22:56:14 +02:00
) -> Result<(u64, bool)> {
2022-10-05 18:36:12 +02:00
self.db.get_or_create_shortstatehash(state_hash)
2021-03-26 11:10:45 +01:00
}
pub fn get_shortroomid(&self, room_id: &RoomId) -> Result<Option<u64>> {
2022-10-05 18:36:12 +02:00
self.db.get_shortroomid(room_id)
}
pub fn get_or_create_shortroomid(
&self,
room_id: &RoomId,
) -> Result<u64> {
2022-10-05 18:36:12 +02:00
self.db.get_or_create_shortroomid(room_id)
}
}