conduwuit/src/service/transaction_ids/mod.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
793 B
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
use std::sync::Arc;
use conduit::Result;
use data::Data;
2022-10-05 20:34:31 +02:00
use ruma::{DeviceId, TransactionId, UserId};
2021-06-08 18:10:00 +02:00
pub struct Service {
pub db: Data,
2020-08-25 13:24:38 +02:00
}
impl crate::Service for Service {
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self {
db: Data::new(args.db),
}))
}
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}
impl Service {
pub fn add_txnid(
&self, user_id: &UserId, device_id: Option<&DeviceId>, txn_id: &TransactionId, data: &[u8],
2020-08-25 13:24:38 +02:00
) -> Result<()> {
2022-10-05 20:33:55 +02:00
self.db.add_txnid(user_id, device_id, txn_id, data)
2020-08-25 13:24:38 +02:00
}
pub fn existing_txnid(
&self, user_id: &UserId, device_id: Option<&DeviceId>, txn_id: &TransactionId,
) -> Result<Option<database::Handle<'_>>> {
2022-10-05 20:33:55 +02:00
self.db.existing_txnid(user_id, device_id, txn_id)
2020-08-25 13:24:38 +02:00
}
}