refactor: acp tpl + config option

- Updated ACP template to match new format
- changed global switch to `activitypubEnabled` (lowercase p)
This commit is contained in:
Julian Lam
2023-06-16 10:57:34 -04:00
parent 0cbbce8c16
commit ab3ff320b5
3 changed files with 20 additions and 20 deletions

View File

@@ -310,7 +310,7 @@ middleware.proceedOnActivityPub = (req, res, next) => {
// For whatever reason, express accepts does not recognize "profile" as a valid differentiator
// Therefore, manual header parsing is used here.
const { accept } = req.headers;
if (!accept || !meta.config.activityPubEnabled) {
if (!accept || !meta.config.activitypubEnabled) {
return next('route');
}

View File

@@ -1,3 +1,4 @@
<div class="acp-page-container">
<!-- IMPORT admin/partials/settings/header.tpl -->
<p class="lead">[[admin/settings/activitypub:intro-lead]]</p>
@@ -5,16 +6,15 @@
<hr />
<div class="row mb-4">
<div class="row settings m-0">
<div class="col-sm-2 col-12 settings-header">[[admin/settings/activitypub:general]]</div>
<div class="col-sm-10 col-12">
<form>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" data-field="activityPubEnabled">
<input class="form-check-input" type="checkbox" data-field="activitypubEnabled">
<label class="form-check-label">[[admin/settings/activitypub:enabled]]</label>
</div>
</form>
</div>
</div>
<!-- IMPORT admin/partials/settings/footer.tpl -->
</div>

View File

@@ -14,11 +14,11 @@ const privileges = require('../src/privileges');
describe('ActivityPub integration', () => {
before(() => {
meta.config.activityPubEnabled = 1;
meta.config.activitypubEnabled = 1;
});
after(() => {
delete meta.config.activityPubEnabled;
delete meta.config.activitypubEnabled;
});
describe('WebFinger endpoint', () => {
@@ -108,7 +108,7 @@ describe('ActivityPub integration', () => {
});
it('should return regular user profile html if federation is disabled', async () => {
delete meta.config.activityPubEnabled;
delete meta.config.activitypubEnabled;
const response = await request(`${nconf.get('url')}/user/${slug}`, {
method: 'get',
@@ -124,7 +124,7 @@ describe('ActivityPub integration', () => {
assert.strictEqual(response.statusCode, 200);
assert(response.body.startsWith('<!DOCTYPE html>'));
meta.config.activityPubEnabled = 1;
meta.config.activitypubEnabled = 1;
});
it('should return regular user profile html if Accept header is not ActivityPub-related', async () => {