mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-20 09:11:24 +01:00
enable unreachable_pub lint
This causes some other lints to start firing too (which is good), but I'm going to fix them in follow-up commits to keep things organized.
This commit is contained in:
parent
a626e7b0f0
commit
d748544f0e
111 changed files with 1007 additions and 876 deletions
|
|
@ -1,17 +1,17 @@
|
|||
mod data;
|
||||
|
||||
pub use data::Data;
|
||||
pub(crate) use data::Data;
|
||||
|
||||
use crate::Result;
|
||||
use ruma::{events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId};
|
||||
|
||||
pub struct Service {
|
||||
pub db: &'static dyn Data,
|
||||
pub(crate) struct Service {
|
||||
pub(crate) db: &'static dyn Data,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
/// Replaces the previous read receipt.
|
||||
pub fn readreceipt_update(
|
||||
pub(crate) fn readreceipt_update(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
|
|
@ -22,7 +22,7 @@ impl Service {
|
|||
|
||||
/// Returns an iterator over the most recent read_receipts in a room that happened after the event with id `since`.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn readreceipts_since<'a>(
|
||||
pub(crate) fn readreceipts_since<'a>(
|
||||
&'a self,
|
||||
room_id: &RoomId,
|
||||
since: u64,
|
||||
|
|
@ -38,18 +38,31 @@ impl Service {
|
|||
|
||||
/// Sets a private read marker at `count`.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn private_read_set(&self, room_id: &RoomId, user_id: &UserId, count: u64) -> Result<()> {
|
||||
pub(crate) fn private_read_set(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
user_id: &UserId,
|
||||
count: u64,
|
||||
) -> Result<()> {
|
||||
self.db.private_read_set(room_id, user_id, count)
|
||||
}
|
||||
|
||||
/// Returns the private read marker.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn private_read_get(&self, room_id: &RoomId, user_id: &UserId) -> Result<Option<u64>> {
|
||||
pub(crate) fn private_read_get(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
user_id: &UserId,
|
||||
) -> Result<Option<u64>> {
|
||||
self.db.private_read_get(room_id, user_id)
|
||||
}
|
||||
|
||||
/// Returns the count of the last typing update in this room.
|
||||
pub fn last_privateread_update(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
|
||||
pub(crate) fn last_privateread_update(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
) -> Result<u64> {
|
||||
self.db.last_privateread_update(user_id, room_id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::Result;
|
||||
use ruma::{events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId};
|
||||
|
||||
pub trait Data: Send + Sync {
|
||||
pub(crate) trait Data: Send + Sync {
|
||||
/// Replaces the previous read receipt.
|
||||
fn readreceipt_update(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -4,16 +4,21 @@ use tokio::sync::{broadcast, RwLock};
|
|||
|
||||
use crate::{services, utils, Result};
|
||||
|
||||
pub struct Service {
|
||||
pub typing: RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>, // u64 is unix timestamp of timeout
|
||||
pub last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>, // timestamp of the last change to typing users
|
||||
pub typing_update_sender: broadcast::Sender<OwnedRoomId>,
|
||||
pub(crate) struct Service {
|
||||
pub(crate) typing: RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>, // u64 is unix timestamp of timeout
|
||||
pub(crate) last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>, // timestamp of the last change to typing users
|
||||
pub(crate) typing_update_sender: broadcast::Sender<OwnedRoomId>,
|
||||
}
|
||||
|
||||
impl Service {
|
||||
/// Sets a user as typing until the timeout timestamp is reached or roomtyping_remove is
|
||||
/// called.
|
||||
pub async fn typing_add(&self, user_id: &UserId, room_id: &RoomId, timeout: u64) -> Result<()> {
|
||||
pub(crate) async fn typing_add(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
timeout: u64,
|
||||
) -> Result<()> {
|
||||
self.typing
|
||||
.write()
|
||||
.await
|
||||
|
|
@ -29,7 +34,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Removes a user from typing before the timeout is reached.
|
||||
pub async fn typing_remove(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
pub(crate) async fn typing_remove(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
self.typing
|
||||
.write()
|
||||
.await
|
||||
|
|
@ -44,7 +49,7 @@ impl Service {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn wait_for_update(&self, room_id: &RoomId) -> Result<()> {
|
||||
pub(crate) async fn wait_for_update(&self, room_id: &RoomId) -> Result<()> {
|
||||
let mut receiver = self.typing_update_sender.subscribe();
|
||||
while let Ok(next) = receiver.recv().await {
|
||||
if next == room_id {
|
||||
|
|
@ -87,7 +92,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns the count of the last typing update in this room.
|
||||
pub async fn last_typing_update(&self, room_id: &RoomId) -> Result<u64> {
|
||||
pub(crate) async fn last_typing_update(&self, room_id: &RoomId) -> Result<u64> {
|
||||
self.typings_maintain(room_id).await?;
|
||||
Ok(self
|
||||
.last_typing_update
|
||||
|
|
@ -99,7 +104,7 @@ impl Service {
|
|||
}
|
||||
|
||||
/// Returns a new typing EDU.
|
||||
pub async fn typings_all(
|
||||
pub(crate) async fn typings_all(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
) -> Result<SyncEphemeralRoomEvent<ruma::events::typing::TypingEventContent>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue