mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
address @r10s and @flub review comments, and fix some docstrings/test meta docs
This commit is contained in:
15
src/chat.rs
15
src/chat.rs
@@ -1,5 +1,5 @@
|
||||
use std::ffi::CString;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::chatlist::*;
|
||||
use crate::constants::*;
|
||||
@@ -187,15 +187,10 @@ impl<'a> Chat<'a> {
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub fn get_profile_image(&self) -> Option<String> {
|
||||
pub fn get_profile_image(&self) -> Option<PathBuf> {
|
||||
if let Some(image_rel) = self.param.get(Param::ProfileImage) {
|
||||
if !image_rel.is_empty() {
|
||||
return Some(
|
||||
dc_get_abs_path_safe(self.context, image_rel)
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
);
|
||||
return Some(dc_get_abs_path_safe(self.context, image_rel));
|
||||
}
|
||||
} else if self.typ == Chattype::Single {
|
||||
let contacts = get_chat_contacts(self.context, self.id);
|
||||
@@ -1658,13 +1653,14 @@ pub unsafe fn set_chat_name(
|
||||
pub fn set_chat_profile_image(
|
||||
context: &Context,
|
||||
chat_id: u32,
|
||||
new_image: impl AsRef<str>,
|
||||
new_image: impl AsRef<str>, // XXX use PathBuf
|
||||
) -> Result<(), Error> {
|
||||
ensure!(chat_id > DC_CHAT_ID_LAST_SPECIAL, "Invalid chat ID");
|
||||
|
||||
let mut chat = Chat::load_from_db(context, chat_id)?;
|
||||
|
||||
if real_group_exists(context, chat_id) {
|
||||
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
|
||||
if !(is_contact_in_chat(context, chat_id, DC_CONTACT_ID_SELF) == 1i32) {
|
||||
log_event!(
|
||||
context,
|
||||
@@ -1672,7 +1668,6 @@ pub fn set_chat_profile_image(
|
||||
0,
|
||||
"Cannot set chat profile image; self not in group.",
|
||||
);
|
||||
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
|
||||
bail!("Failed to set profile image");
|
||||
}
|
||||
let mut new_image_rel: String;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use deltachat_derive::*;
|
||||
use itertools::Itertools;
|
||||
use rusqlite;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::aheader::EncryptPreference;
|
||||
use crate::config::Config;
|
||||
@@ -766,9 +767,11 @@ impl<'a> Contact<'a> {
|
||||
/// Get the contact's profile image.
|
||||
/// This is the image set by each remote user on their own
|
||||
/// using dc_set_config(context, "selfavatar", image).
|
||||
pub fn get_profile_image(&self) -> Option<String> {
|
||||
pub fn get_profile_image(&self) -> Option<PathBuf> {
|
||||
if self.id == DC_CONTACT_ID_SELF {
|
||||
return self.context.get_config(Config::Selfavatar);
|
||||
if let Some(p) = self.context.get_config(Config::Selfavatar) {
|
||||
return Some(PathBuf::from(p));
|
||||
}
|
||||
}
|
||||
// TODO: else get image_abs from contact param
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user