feat: show category followers in category federation ACP page

This commit is contained in:
Julian Lam
2024-06-11 11:24:22 -04:00
parent 2c87c6e82f
commit 7313d5c614
4 changed files with 50 additions and 1 deletions

View File

@@ -90,6 +90,10 @@
"federation.syncing-actorUri": "Actor",
"federation.syncing-follow": "Follow",
"federation.syncing-unfollow": "Unfollow",
"federation.followers": "Remote users following this category",
"federation.followers-handle": "Handle",
"federation.followers-id": "ID",
"federation.followers-none": "No followers.",
"alert.created": "Created",
"alert.create-success": "Category successfully created!",

View File

@@ -36,6 +36,11 @@ export function init() {
break;
}
case 'autofill': {
const uid = $(this).parents('[data-uid]').attr('data-uid');
$('#syncing-add').val(uid);
}
}
});
}

View File

@@ -3,11 +3,13 @@
const _ = require('lodash');
const nconf = require('nconf');
const db = require('../../database');
const user = require('../../user');
const categories = require('../../categories');
const analytics = require('../../analytics');
const plugins = require('../../plugins');
const translator = require('../../translator');
const meta = require('../../meta');
const activitypub = require('../../activitypub');
const helpers = require('../helpers');
const pagination = require('../../pagination');
@@ -149,9 +151,10 @@ categoriesController.getAnalytics = async function (req, res) {
categoriesController.getFederation = async function (req, res) {
const cid = req.params.category_id;
const [_following, pending, name, { selectedCategory }] = await Promise.all([
let [_following, pending, followers, name, { selectedCategory }] = await Promise.all([
db.getSortedSetMembers(`cid:${cid}:following`),
db.getSortedSetMembers(`followRequests:cid.${cid}`),
activitypub.notes.getCategoryFollowers(cid),
categories.getCategoryField(cid, 'name'),
helpers.getSelectedCategory(cid),
]);
@@ -161,11 +164,15 @@ categoriesController.getFederation = async function (req, res) {
approved: !pending.includes(entry),
}));
await activitypub.actors.assert(followers);
followers = await user.getUsersFields(followers, ['userslug', 'picture']);
res.render('admin/manage/category-federation', {
cid: cid,
enabled: meta.config.activitypubEnabled,
name,
selectedCategory,
following,
followers,
});
};

View File

@@ -58,6 +58,39 @@
<button data-action="follow" type="button" class="btn btn-primary">[[admin/manage/categories:federation.syncing-follow]]</button>
</div>
</div>
<hr />
<div class="mb-3">
<p>[[admin/manage/categories:federation.followers]]</p>
<table class="table small">
<tr>
<th>[[admin/manage/categories:federation.followers-handle]]</th>
<th>[[admin/manage/categories:federation.followers-id]]</th>
</tr>
{{{ if !followers.length}}}
<tr>
<td class="text-center border-0" colspan="2">
<em>[[admin/manage/categories:federation.followers-none]]</em>
</td>
</tr>
{{{ end }}}
{{{ each followers }}}
<tr data-uid="{./uid}">
<td>
{buildAvatar(followers, "24px", true)}
{./userslug}
</td>
<td>
<code>{./uid}</code>
<button type="button" class="btn btn-link" data-action="autofill">
<i class="fa fa-exchange-alt"></i>
</button>
</td>
</tr>
{{{ end }}}
</table>
</div>
</form>
</div>
</div>