Fix 'yes'/'no' toggles, consts for well known conf tags/etc.

This commit is contained in:
Bryan Ashby 2023-02-20 20:09:58 -07:00
parent 2495430fae
commit f264e4886e
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
6 changed files with 47 additions and 23 deletions

View File

@ -907,14 +907,14 @@ module.exports = () => {
}, },
}, },
activity_pub: { activitypub_internal: {
name: 'ActivityPub Shared Inbox', name: 'ActivityPub',
desc: 'Public and shared ActivityPub messages', desc: 'Public ActivityPub messages',
areas: { areas: {
activitypub_shared: { activitypub_shared: {
name: 'ActivityPub sharedInbox', name: 'ActivityPub Public',
desc: 'Public shared inbox for ActivityPub', desc: 'Public inbox for ActivityPub',
alwaysExportExternal: true, alwaysExportExternal: true,
subjectOptional: true, subjectOptional: true,
addressFlavor: 'activitypub', addressFlavor: 'activitypub',

View File

@ -11,6 +11,11 @@ const sortAreasOrConfs = require('./conf_area_util.js').sortAreasOrConfs;
const UserProps = require('./user_property.js'); const UserProps = require('./user_property.js');
const StatLog = require('./stat_log.js'); const StatLog = require('./stat_log.js');
const SysProps = require('./system_property.js'); const SysProps = require('./system_property.js');
const {
SystemInternalConfTags,
WellKnownConfTags,
WellKnownAreaTags,
} = require('./message_const');
// deps // deps
const async = require('async'); const async = require('async');
@ -93,9 +98,9 @@ function getAvailableMessageConferences(client, options) {
assert(client || true === options.noClient); assert(client || true === options.noClient);
// perform ACS check per conf & omit system_internal if desired // perform ACS check per conf & omit "System Internal" if desired
return _.omitBy(Config().messageConferences, (conf, confTag) => { return _.omitBy(Config().messageConferences, (conf, confTag) => {
if (!options.includeSystemInternal && 'system_internal' === confTag) { if (!options.includeSystemInternal && SystemInternalConfTags.includes(confTag)) {
return true; return true;
} }
@ -178,7 +183,7 @@ function getDefaultMessageConferenceTag(client, disableAcsCheck) {
// //
// It's possible that we end up with nothing here! // It's possible that we end up with nothing here!
// //
// Note that built in 'system_internal' is always ommited here // Note that built in "System Internal" are always omitted here
// //
const config = Config(); const config = Config();
let defaultConf = _.findKey(config.messageConferences, o => o.default); let defaultConf = _.findKey(config.messageConferences, o => o.default);
@ -192,7 +197,7 @@ function getDefaultMessageConferenceTag(client, disableAcsCheck) {
// just use anything we can // just use anything we can
defaultConf = _.findKey(config.messageConferences, (conf, confTag) => { defaultConf = _.findKey(config.messageConferences, (conf, confTag) => {
return ( return (
'system_internal' !== confTag && !SystemInternalConfTags.includes(confTag) &&
(true === disableAcsCheck || client.acs.hasMessageConfRead(conf)) (true === disableAcsCheck || client.acs.hasMessageConfRead(conf))
); );
}); });
@ -545,7 +550,7 @@ function getNewMessageCountAddressedToUser(client, cb) {
areaTags, areaTags,
(areaTag, nextAreaTag) => { (areaTag, nextAreaTag) => {
getMessageAreaLastReadId(client.user.userId, areaTag, (_, lastMessageId) => { getMessageAreaLastReadId(client.user.userId, areaTag, (_, lastMessageId) => {
lastMessageId = lastMessageId || 0; lastMessageId = lastMessageId || 0; // eslint-disable-line no-unused-vars
getNewMessageCountInAreaForUser( getNewMessageCountInAreaForUser(
client.user.userId, client.user.userId,
areaTag, areaTag,
@ -847,7 +852,13 @@ function trimMessageAreasScheduledEvent(args, cb) {
// //
const maxExternalSentAgeDays = _.get( const maxExternalSentAgeDays = _.get(
Config, Config,
'messageConferences.system_internal.areas.private_mail.maxExternalSentAgeDays', [
'messageConferences',
WellKnownConfTags.SystemInternal,
'areas',
WellKnownAreaTags.Private,
'maxExternalSentAgeDays',
],
30 30
); );

View File

@ -1,3 +1,15 @@
const WellKnownConfTags = {
Invalid: '',
SystemInternal: 'system_internal',
ActivityPubInternal: 'activitypub_internal',
};
exports.WellKnownConfTags = WellKnownConfTags;
exports.SystemInternalConfTags = [
WellKnownConfTags.SystemInternal,
WellKnownConfTags.ActivityPubInternal,
];
const WellKnownAreaTags = { const WellKnownAreaTags = {
Invalid: '', Invalid: '',
Private: 'private_mail', Private: 'private_mail',

View File

@ -11,6 +11,7 @@ const FileBaseFilters = require('./file_base_filter.js');
const Errors = require('./enig_error.js').Errors; const Errors = require('./enig_error.js').Errors;
const { getAvailableFileAreaTags } = require('./file_base_area.js'); const { getAvailableFileAreaTags } = require('./file_base_area.js');
const { valueAsArray } = require('./misc_util.js'); const { valueAsArray } = require('./misc_util.js');
const { SystemInternalConfTags } = require('./message_const');
// deps // deps
const _ = require('lodash'); const _ = require('lodash');
@ -80,12 +81,12 @@ exports.getModule = class NewScanModule extends MenuModule {
); );
// //
// Sort conferences by name, other than 'system_internal' which should // Sort conferences by name, other than "System Internal" which should
// always come first such that we display private mails/etc. before // always come first such that we display private mails/etc. before
// other conferences & areas // other conferences & areas
// //
this.sortedMessageConfs.sort((a, b) => { this.sortedMessageConfs.sort((a, b) => {
if ('system_internal' === a.confTag) { if (SystemInternalConfTags.includes(a.confTag)) {
return -1; return -1;
} else { } else {
return a.conf.name.localeCompare(b.conf.name, { return a.conf.name.localeCompare(b.conf.name, {

View File

@ -78,17 +78,17 @@ ToggleMenuView.prototype.setFocusItemIndex = function (index) {
}; };
ToggleMenuView.prototype.setTrue = function () { ToggleMenuView.prototype.setTrue = function () {
this.setFocusItemIndex(0);
this.updateSelection();
};
ToggleMenuView.prototype.setFalse = function () {
this.setFocusItemIndex(1); this.setFocusItemIndex(1);
this.updateSelection(); this.updateSelection();
}; };
ToggleMenuView.prototype.setFalse = function () {
this.setFocusItemIndex(0);
this.updateSelection();
};
ToggleMenuView.prototype.isTrue = function () { ToggleMenuView.prototype.isTrue = function () {
return this.focusedItemIndex === 0; return this.focusedItemIndex === 1;
}; };
ToggleMenuView.prototype.setFromBoolean = function (bool) { ToggleMenuView.prototype.setFromBoolean = function (bool) {

View File

@ -87,19 +87,19 @@
mci: { mci: {
TM1: { TM1: {
focus: true focus: true
items: ["yes", "no"] items: ["no", "yes"]
argName: enabled argName: enabled
} }
TM2: { TM2: {
items: ["yes", "no"] items: ["no", "yes"]
argName: manuallyApproveFollowers argName: manuallyApproveFollowers
} }
TM3: { TM3: {
items: ["yes", "no"] items: ["no", "yes"]
argName: hideSocialGraph argName: hideSocialGraph
} }
TM4: { TM4: {
items: ["yes", "no"] items: ["no", "yes"]
argName: showRealName argName: showRealName
} }
TL5: {argName: "image"} TL5: {argName: "image"}