Replace profile_* with userid_*
Add a missing dot in the errormessage Require mxc:// to be present at the start of an avatar_url Update mxc check TODO Show displayname or avatar_url if either is available when getting the profile Endpoint Return the correct data in case of a empty displayname or an empty avatar_url Took 50 minutes Took 34 seconds
This commit is contained in:
parent
062c5521f0
commit
b1284fd509
3 changed files with 91 additions and 52 deletions
18
src/data.rs
18
src/data.rs
|
@ -60,10 +60,15 @@ impl Data {
|
|||
.map(|bytes| utils::string_from_bytes(&bytes))
|
||||
}
|
||||
|
||||
/// Removes a displayname.
|
||||
pub fn displayname_remove(&self, user_id: &UserId) {
|
||||
self.db.userid_displayname.remove(user_id).unwrap();
|
||||
}
|
||||
|
||||
/// Set a new displayname.
|
||||
pub fn displayname_set(&self, user_id: &UserId, displayname: Option<String>) {
|
||||
self.db
|
||||
.profile_displayname
|
||||
.userid_displayname
|
||||
.insert(user_id.to_string(), &*displayname.unwrap_or_default())
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -71,16 +76,21 @@ impl Data {
|
|||
/// Get a the displayname of a user.
|
||||
pub fn displayname_get(&self, user_id: &UserId) -> Option<String> {
|
||||
self.db
|
||||
.profile_displayname
|
||||
.userid_displayname
|
||||
.get(user_id.to_string())
|
||||
.unwrap()
|
||||
.map(|bytes| utils::string_from_bytes(&bytes))
|
||||
}
|
||||
|
||||
/// Removes a avatar_url.
|
||||
pub fn avatar_url_remove(&self, user_id: &UserId) {
|
||||
self.db.userid_avatar_url.remove(user_id).unwrap();
|
||||
}
|
||||
|
||||
/// Set a new avatar_url.
|
||||
pub fn avatar_url_set(&self, user_id: &UserId, avatar_url: String) {
|
||||
self.db
|
||||
.profile_avatar_url
|
||||
.userid_avatar_url
|
||||
.insert(user_id.to_string(), &*avatar_url)
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -88,7 +98,7 @@ impl Data {
|
|||
/// Get a the avatar_url of a user.
|
||||
pub fn avatar_url_get(&self, user_id: &UserId) -> Option<String> {
|
||||
self.db
|
||||
.profile_avatar_url
|
||||
.userid_avatar_url
|
||||
.get(user_id.to_string())
|
||||
.unwrap()
|
||||
.map(|bytes| utils::string_from_bytes(&bytes))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue