Compare commits
1 commit
main
...
room-delet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c98cdbb7a8 |
2 changed files with 20 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use ruma::{events::StateEventType, EventId, RoomId};
|
||||
use tracing::warn;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use crate::{database::KeyValueDatabase, service, services, utils, Error, Result};
|
||||
|
||||
|
@ -216,4 +216,21 @@ impl service::rooms::short::Data for KeyValueDatabase {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Attempts to delete a shortroomid from the kv database
|
||||
fn delete_shortroomid(&self, room_id: &RoomId) -> Result<()> {
|
||||
Ok(match self.roomid_shortroomid.get(room_id.as_bytes())? {
|
||||
Some(short) => {
|
||||
self.roomid_shortroomid.remove(&short).map_err(|e| {
|
||||
error!("Failed to remove shortroomid in database: {e}");
|
||||
Error::bad_database("Failed to remove shortroomid in database")
|
||||
});
|
||||
}
|
||||
None => {
|
||||
return Err(Error::bad_database(
|
||||
"Invalid or non-existent shortroomid in db.",
|
||||
))?
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,6 @@ pub trait Data: Send + Sync {
|
|||
fn get_shortroomid(&self, room_id: &RoomId) -> Result<Option<u64>>;
|
||||
|
||||
fn get_or_create_shortroomid(&self, room_id: &RoomId) -> Result<u64>;
|
||||
|
||||
fn delete_shortroomid(&self, room_id: &RoomId) -> Result<()>;
|
||||
}
|
||||
|
|
Reference in a new issue