[mastodon-client] Respect ffVisibility

This commit is contained in:
Laura Hausmann 2023-10-04 23:06:17 +02:00
parent a515b6b4d4
commit 7f6ac71dd0
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -37,6 +37,30 @@ export class UserConverter {
? (DriveFiles.findOneBy({id: u.bannerId})) ? (DriveFiles.findOneBy({id: u.bannerId}))
.then(p => p?.url ?? `${config.url}/static-assets/transparent.png`) .then(p => p?.url ?? `${config.url}/static-assets/transparent.png`)
: `${config.url}/static-assets/transparent.png`; : `${config.url}/static-assets/transparent.png`;
const followersCount = profile.then(profile => {
if (profile === null) return u.followersCount;
switch (profile.ffVisibility) {
case "public":
return u.followersCount;
case "followers":
// FIXME: check following relationship
return 0;
case "private":
return 0;
}
});
const followingCount = profile.then(profile => {
if (profile === null) return u.followingCount;
switch (profile.ffVisibility) {
case "public":
return u.followingCount;
case "followers":
// FIXME: check following relationship
return 0;
case "private":
return 0;
}
});
return awaitAll({ return awaitAll({
id: u.id, id: u.id,
@ -45,8 +69,8 @@ export class UserConverter {
display_name: u.name || u.username, display_name: u.name || u.username,
locked: u.isLocked, locked: u.isLocked,
created_at: u.createdAt.toISOString(), created_at: u.createdAt.toISOString(),
followers_count: u.followersCount, followers_count: followersCount,
following_count: u.followingCount, following_count: followingCount,
statuses_count: u.notesCount, statuses_count: u.notesCount,
note: bio, note: bio,
url: u.uri ?? acctUrl, url: u.uri ?? acctUrl,