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

View File

@@ -1,20 +1,20 @@
<!-- IMPORT admin/partials/settings/header.tpl --> <div class="acp-page-container">
<!-- IMPORT admin/partials/settings/header.tpl -->
<p class="lead">[[admin/settings/activitypub:intro-lead]]</p> <p class="lead">[[admin/settings/activitypub:intro-lead]]</p>
<p>[[admin/settings/activitypub:intro-body]]</p> <p>[[admin/settings/activitypub:intro-body]]</p>
<hr /> <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-2 col-12 settings-header">[[admin/settings/activitypub:general]]</div>
<div class="col-sm-10 col-12"> <div class="col-sm-10 col-12">
<form> <form>
<div class="form-check form-switch mb-3"> <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> <label class="form-check-label">[[admin/settings/activitypub:enabled]]</label>
</div> </div>
</form> </form>
</div>
</div> </div>
</div> </div>
<!-- IMPORT admin/partials/settings/footer.tpl -->

View File

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