~vpzom/lotide

8797de5e2981bc73780515959a46c946da8f2c6f — Colin Reeder 11 months ago ecc0753
Add avatar processing to (hopefully) the remaining cases
M src/routes/api/comments.rs => src/routes/api/comments.rs +8 -3
@@ 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),
                    }),
                },
            }
        })

M src/routes/api/communities.rs => src/routes/api/communities.rs +8 -5
@@ 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),
                    }),
                }
            });


M src/routes/api/mod.rs => src/routes/api/mod.rs +2 -2
@@ 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(),
                    }),
                }
            });

M src/routes/api/posts.rs => src/routes/api/posts.rs +9 -4
@@ 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),
                    }),
                },
            }
        })