summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-10-28 09:46:41 -0600
committerColin Reeder <colin@vpzom.click>2020-10-28 09:46:41 -0600
commit8797de5e2981bc73780515959a46c946da8f2c6f (patch)
tree8576836c14f3ff8a756b73affea2eab81e7507a5
parentecc07534b643c8554b2e82c658c16728678c8d7c (diff)
Add avatar processing to (hopefully) the remaining cases
-rw-r--r--src/routes/api/comments.rs11
-rw-r--r--src/routes/api/communities.rs13
-rw-r--r--src/routes/api/mod.rs4
-rw-r--r--src/routes/api/posts.rs13
4 files changed, 27 insertions, 14 deletions
diff --git a/src/routes/api/comments.rs b/src/routes/api/comments.rs
index 34b1de4..6a9375d 100644
--- a/src/routes/api/comments.rs
+++ b/src/routes/api/comments.rs
@@ -66,11 +66,12 @@ async fn route_unstable_comments_get(
let created: chrono::DateTime<chrono::FixedOffset> = row.get(3);
let author = match row.get(6) {
Some(author_username) => {
+ let author_id = UserLocalID(row.get(0));
let author_local = row.get(7);
let author_ap_id = row.get(8);
let author_avatar: Option<&str> = row.get(12);
Some(RespMinimalAuthorInfo {
- id: UserLocalID(row.get(0)),
+ id: author_id,
username: Cow::Borrowed(author_username),
local: author_local,
host: crate::get_actor_host_or_unknown(
@@ -79,7 +80,9 @@ async fn route_unstable_comments_get(
&ctx.local_hostname,
),
remote_url: author_ap_id.map(From::from),
- avatar: author_avatar.map(|url| RespAvatarInfo { url: url.into() }),
+ avatar: author_avatar.map(|url| RespAvatarInfo {
+ url: ctx.process_avatar_href(url, author_id),
+ }),
})
}
None => None,
@@ -395,7 +398,9 @@ async fn route_unstable_comments_likes_list(
local,
host: crate::get_actor_host_or_unknown(local, ap_id, &ctx.local_hostname),
remote_url: ap_id.map(From::from),
- avatar: avatar.map(|url| RespAvatarInfo { url: url.into() }),
+ avatar: avatar.map(|url| RespAvatarInfo {
+ url: ctx.process_avatar_href(url, id),
+ }),
},
}
})
diff --git a/src/routes/api/communities.rs b/src/routes/api/communities.rs
index e348f94..89215b0 100644
--- a/src/routes/api/communities.rs
+++ b/src/routes/api/communities.rs
@@ -361,18 +361,19 @@ async fn route_unstable_communities_moderators_list(
let output: Vec<_> = rows
.iter()
.map(|row| {
+ let id = UserLocalID(row.get(0));
let local = row.get(2);
let ap_id = row.get(3);
RespMinimalAuthorInfo {
- id: UserLocalID(row.get(0)),
+ id,
username: Cow::Borrowed(row.get(1)),
local,
host: crate::get_actor_host_or_unknown(local, ap_id, &ctx.local_hostname),
remote_url: ap_id.map(|x| x.into()),
- avatar: row
- .get::<_, Option<&str>>(4)
- .map(|url| RespAvatarInfo { url: url.into() }),
+ avatar: row.get::<_, Option<&str>>(4).map(|url| RespAvatarInfo {
+ url: ctx.process_avatar_href(url, id),
+ }),
}
})
.collect();
@@ -633,7 +634,9 @@ async fn route_unstable_communities_posts_list(
}
},
remote_url: author_ap_id.map(From::from),
- avatar: author_avatar.map(|url| RespAvatarInfo { url: url.into() }),
+ avatar: author_avatar.map(|url| RespAvatarInfo {
+ url: ctx.process_avatar_href(url, id),
+ }),
}
});
diff --git a/src/routes/api/mod.rs b/src/routes/api/mod.rs
index 13fbd33..05a338b 100644
--- a/src/routes/api/mod.rs
+++ b/src/routes/api/mod.rs
@@ -680,7 +680,7 @@ async fn get_comments_replies<'a>(
),
remote_url: author_ap_id.map(|x| x.to_owned().into()),
avatar: author_avatar.map(|url| RespAvatarInfo {
- url: url.to_owned().into(),
+ url: ctx.process_avatar_href(url, author_id).into_owned().into(),
}),
}
});
@@ -790,7 +790,7 @@ async fn handle_common_posts_list(
),
remote_url: author_ap_id.map(|x| x.to_owned().into()),
avatar: author_avatar.map(|url| RespAvatarInfo {
- url: url.to_owned().into(),
+ url: ctx.process_avatar_href(url, id).into_owned().into(),
}),
}
});
diff --git a/src/routes/api/posts.rs b/src/routes/api/posts.rs
index 731b979..4f4c373 100644
--- a/src/routes/api/posts.rs
+++ b/src/routes/api/posts.rs
@@ -58,7 +58,7 @@ async fn get_post_comments<'a>(
),
remote_url: author_ap_id.map(|x| x.to_owned().into()),
avatar: author_avatar.map(|url| RespAvatarInfo {
- url: url.to_owned().into(),
+ url: ctx.process_avatar_href(url, author_id).into_owned().into(),
}),
}
});
@@ -324,11 +324,12 @@ async fn route_unstable_posts_get(
let author = match row.get(10) {
Some(author_username) => {
+ let author_id = UserLocalID(row.get(0));
let author_local = row.get(11);
let author_ap_id = row.get(12);
let author_avatar: Option<&str> = row.get(15);
Some(RespMinimalAuthorInfo {
- id: UserLocalID(row.get(0)),
+ id: author_id,
username: Cow::Borrowed(author_username),
local: author_local,
host: crate::get_actor_host_or_unknown(
@@ -337,7 +338,9 @@ async fn route_unstable_posts_get(
&ctx.local_hostname,
),
remote_url: author_ap_id.map(From::from),
- avatar: author_avatar.map(|url| RespAvatarInfo { url: url.into() }),
+ avatar: author_avatar.map(|url| RespAvatarInfo {
+ url: ctx.process_avatar_href(url, author_id),
+ }),
})
}
None => None,
@@ -634,7 +637,9 @@ async fn route_unstable_posts_likes_list(
local,
host: crate::get_actor_host_or_unknown(local, ap_id, &ctx.local_hostname),
remote_url: ap_id.map(From::from),
- avatar: avatar.map(|url| RespAvatarInfo { url: url.into() }),
+ avatar: avatar.map(|url| RespAvatarInfo {
+ url: ctx.process_avatar_href(url, id),
+ }),
},
}
})