mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-14 16:01:01 +00:00
Allow empty avatar for remote users
This commit is contained in:
parent
399af4004a
commit
f138ae6ed9
1 changed files with 7 additions and 17 deletions
|
@ -256,23 +256,13 @@ impl User {
|
|||
|
||||
pub fn refetch(&self, conn: &Connection) -> Result<()> {
|
||||
User::fetch(&self.ap_url.clone()).and_then(|json| {
|
||||
let avatar = Media::save_remote(
|
||||
conn,
|
||||
json.ap_actor_ref()
|
||||
let avatar = json
|
||||
.icon()
|
||||
.ok_or(Error::MissingApProperty)? // FIXME: Fails when icon is not set
|
||||
.iter()
|
||||
.next()
|
||||
.and_then(|i| {
|
||||
i.clone()
|
||||
.extend::<Image, ImageType>() // FIXME: Don't clone()
|
||||
.ok()?
|
||||
.and_then(|url| Some(url.id_unchecked()?.to_string()))
|
||||
})
|
||||
.ok_or(Error::MissingApProperty)?,
|
||||
self,
|
||||
)
|
||||
.ok();
|
||||
.and_then(|icon| icon.iter().next())
|
||||
.and_then(|i| i.clone().extend::<Image, ImageType>().ok())
|
||||
.and_then(|image| image)
|
||||
.and_then(|image| image.id_unchecked().map(|url| url.to_string()))
|
||||
.and_then(|url| Media::save_remote(conn, url, self).ok());
|
||||
|
||||
let pub_key = &json.ext_one.public_key.public_key_pem;
|
||||
diesel::update(self)
|
||||
|
|
Loading…
Reference in a new issue