New MCI for AP subject, show subj and custom info format on config
This commit is contained in:
parent
a09fe4894f
commit
df55c3fa6d
Binary file not shown.
|
@ -430,6 +430,9 @@
|
||||||
|
|
||||||
// :TODO: move this to the right area, rename, etc.
|
// :TODO: move this to the right area, rename, etc.
|
||||||
mainMenuActivityPubUserConfig: {
|
mainMenuActivityPubUserConfig: {
|
||||||
|
config: {
|
||||||
|
mainInfoFormat10: "{subject}"
|
||||||
|
}
|
||||||
0: {
|
0: {
|
||||||
mci: {
|
mci: {
|
||||||
TM1: {
|
TM1: {
|
||||||
|
@ -459,6 +462,9 @@
|
||||||
TM8: {
|
TM8: {
|
||||||
focusTextStyle: first lower
|
focusTextStyle: first lower
|
||||||
}
|
}
|
||||||
|
TL10: {
|
||||||
|
width: 40
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,7 +270,7 @@ module.exports = class Note extends ActivityPubObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the Note is marked sensitive, prefix the subject
|
// If the Note is marked sensitive, prefix the subject
|
||||||
if (this.sensitive) {
|
if (this.sensitive && message.subject.indexOf('[NSFW]') === -1) {
|
||||||
message.subject = `[NSFW] ${message.subject}`;
|
message.subject = `[NSFW] ${message.subject}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const { MenuModule } = require('../menu_module');
|
const { MenuModule } = require('../menu_module');
|
||||||
const ActivityPubSettings = require('./settings');
|
const ActivityPubSettings = require('./settings');
|
||||||
const { Errors } = require('../enig_error');
|
const { Errors } = require('../enig_error');
|
||||||
|
const { getServer } = require('../listening_server');
|
||||||
|
const { userNameToSubject } = require('./util');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
@ -27,9 +29,20 @@ const MciViewIds = {
|
||||||
icon: 6,
|
icon: 6,
|
||||||
manageImagesButton: 7,
|
manageImagesButton: 7,
|
||||||
saveOrCancel: 8,
|
saveOrCancel: 8,
|
||||||
|
|
||||||
|
customRangeStart: 10,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const EnabledViewGroup = [
|
||||||
|
MciViewIds.main.manuallyApproveFollowersToggle,
|
||||||
|
MciViewIds.main.hideSocialGraphToggle,
|
||||||
|
MciViewIds.main.showRealNameToggle,
|
||||||
|
MciViewIds.main.image,
|
||||||
|
MciViewIds.main.icon,
|
||||||
|
MciViewIds.main.manageImagesButton,
|
||||||
|
];
|
||||||
|
|
||||||
exports.getModule = class ActivityPubUserConfig extends MenuModule {
|
exports.getModule = class ActivityPubUserConfig extends MenuModule {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
@ -159,6 +172,14 @@ exports.getModule = class ActivityPubUserConfig extends MenuModule {
|
||||||
truncate(apSettings.icon, { length: iconView.getWidth() })
|
truncate(apSettings.icon, { length: iconView.getWidth() })
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._toggleEnabledViewGroup();
|
||||||
|
this._updateCustomViews();
|
||||||
|
|
||||||
|
enabledToggleView.on('index update', () => {
|
||||||
|
this._toggleEnabledViewGroup();
|
||||||
|
this._updateCustomViews();
|
||||||
|
});
|
||||||
|
|
||||||
return callback(null);
|
return callback(null);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -167,4 +188,40 @@ exports.getModule = class ActivityPubUserConfig extends MenuModule {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_toggleEnabledViewGroup() {
|
||||||
|
const enabledToggleView = this.getView('main', MciViewIds.main.enabledToggle);
|
||||||
|
EnabledViewGroup.forEach(id => {
|
||||||
|
const v = this.getView('main', id);
|
||||||
|
v.acceptsFocus = enabledToggleView.isTrue();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateCustomViews() {
|
||||||
|
const enabledToggleView = this.getView('main', MciViewIds.main.enabledToggle);
|
||||||
|
const ws = this._webServer();
|
||||||
|
const enabled = enabledToggleView.isTrue();
|
||||||
|
const formatObj = {
|
||||||
|
enabled,
|
||||||
|
status: enabled ? 'enabled' : 'disabled',
|
||||||
|
subject: enabled
|
||||||
|
? ws
|
||||||
|
? userNameToSubject(this.client.user.username, ws)
|
||||||
|
: 'N/A'
|
||||||
|
: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
this.updateCustomViewTextsWithFilter(
|
||||||
|
'main',
|
||||||
|
MciViewIds.main.customRangeStart,
|
||||||
|
formatObj
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_webServer() {
|
||||||
|
if (undefined === this.webServer) {
|
||||||
|
this.webServer = getServer('codes.l33t.enigma.web.server');
|
||||||
|
}
|
||||||
|
return this.webServer ? this.webServer.instance : null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@ exports.messageBodyToHtml = messageBodyToHtml;
|
||||||
exports.messageToHtml = messageToHtml;
|
exports.messageToHtml = messageToHtml;
|
||||||
exports.htmlToMessageBody = htmlToMessageBody;
|
exports.htmlToMessageBody = htmlToMessageBody;
|
||||||
exports.userNameFromSubject = userNameFromSubject;
|
exports.userNameFromSubject = userNameFromSubject;
|
||||||
|
exports.userNameToSubject = userNameToSubject;
|
||||||
exports.extractMessageMetadata = extractMessageMetadata;
|
exports.extractMessageMetadata = extractMessageMetadata;
|
||||||
exports.recipientIdsFromObject = recipientIdsFromObject;
|
exports.recipientIdsFromObject = recipientIdsFromObject;
|
||||||
exports.sendFollowRequest = sendFollowRequest;
|
exports.sendFollowRequest = sendFollowRequest;
|
||||||
|
@ -144,7 +145,7 @@ function getUserProfileTemplatedBody(
|
||||||
|
|
||||||
const varMap = {
|
const varMap = {
|
||||||
ACTOR_OBJ: JSON.stringify(userAsActor),
|
ACTOR_OBJ: JSON.stringify(userAsActor),
|
||||||
SUBJECT: `@${user.username}@${webServer.getDomain()}`,
|
SUBJECT: userNameToSubject(user.username, webServer),
|
||||||
INBOX: userAsActor.inbox,
|
INBOX: userAsActor.inbox,
|
||||||
SHARED_INBOX: userAsActor.endpoints.sharedInbox,
|
SHARED_INBOX: userAsActor.endpoints.sharedInbox,
|
||||||
OUTBOX: userAsActor.outbox,
|
OUTBOX: userAsActor.outbox,
|
||||||
|
@ -228,6 +229,10 @@ function userNameFromSubject(subject) {
|
||||||
return subject.replace(/^acct:(.+)$/, '$1');
|
return subject.replace(/^acct:(.+)$/, '$1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function userNameToSubject(userName, webServer) {
|
||||||
|
return `@${userName}@${webServer.getDomain()}`;
|
||||||
|
}
|
||||||
|
|
||||||
function extractMessageMetadata(body) {
|
function extractMessageMetadata(body) {
|
||||||
const metadata = { mentions: new Set(), hashTags: new Set() };
|
const metadata = { mentions: new Set(), hashTags: new Set() };
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ const ANSI = require('./ansi_term.js');
|
||||||
const UserProps = require('./user_property.js');
|
const UserProps = require('./user_property.js');
|
||||||
const SysProps = require('./system_property.js');
|
const SysProps = require('./system_property.js');
|
||||||
const SysLogKeys = require('./system_log.js');
|
const SysLogKeys = require('./system_log.js');
|
||||||
|
const ActivityPubSettings = require('./activitypub/settings');
|
||||||
|
const { userNameToSubject } = require('./activitypub/util');
|
||||||
|
const { getServer } = require('./listening_server');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const packageJson = require('../package.json');
|
const packageJson = require('../package.json');
|
||||||
|
@ -82,6 +85,15 @@ function userStatAsCountString(client, statName, defaultValue) {
|
||||||
return toNumberWithCommas(value);
|
return toNumberWithCommas(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lazy cache
|
||||||
|
let cachedWebServer;
|
||||||
|
function getWebServer() {
|
||||||
|
if (undefined === cachedWebServer) {
|
||||||
|
cachedWebServer = getServer('codes.l33t.enigma.web.server');
|
||||||
|
}
|
||||||
|
return cachedWebServer ? cachedWebServer.instance : null;
|
||||||
|
}
|
||||||
|
|
||||||
const PREDEFINED_MCI_GENERATORS = {
|
const PREDEFINED_MCI_GENERATORS = {
|
||||||
//
|
//
|
||||||
// Board
|
// Board
|
||||||
|
@ -133,6 +145,17 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||||
UR: function realName(client) {
|
UR: function realName(client) {
|
||||||
return userStatAsString(client, UserProps.RealName, '');
|
return userStatAsString(client, UserProps.RealName, '');
|
||||||
},
|
},
|
||||||
|
AS: function activityPubSubjectName(client) {
|
||||||
|
const activityPubSettings = ActivityPubSettings.fromUser(client.user);
|
||||||
|
if (!activityPubSettings.enabled) {
|
||||||
|
return '(disabled)';
|
||||||
|
}
|
||||||
|
const webServer = getWebServer();
|
||||||
|
if (!webServer) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
return userNameToSubject(client.user.username, webServer);
|
||||||
|
},
|
||||||
LO: function location(client) {
|
LO: function location(client) {
|
||||||
return userStatAsString(client, UserProps.Location, '');
|
return userStatAsString(client, UserProps.Location, '');
|
||||||
},
|
},
|
||||||
|
|
|
@ -87,6 +87,10 @@ ToggleMenuView.prototype.setFalse = function () {
|
||||||
this.updateSelection();
|
this.updateSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ToggleMenuView.prototype.isTrue = function () {
|
||||||
|
return this.focusedItemIndex === 0;
|
||||||
|
};
|
||||||
|
|
||||||
ToggleMenuView.prototype.setFromBoolean = function (bool) {
|
ToggleMenuView.prototype.setFromBoolean = function (bool) {
|
||||||
return bool ? this.setTrue() : this.setFalse();
|
return bool ? this.setTrue() : this.setFalse();
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,7 @@ There are many predefined MCI codes that can be used anywhere on the system (pla
|
||||||
| `UI` | Current user's user ID |
|
| `UI` | Current user's user ID |
|
||||||
| `UG` | Current user's group membership(s) |
|
| `UG` | Current user's group membership(s) |
|
||||||
| `UR` | Current user's real name |
|
| `UR` | Current user's real name |
|
||||||
|
| `AS` | ActivityPub subject, ie: "@SomeUser@yourhost.com", "(disabled)" if AP is not enabled for the user |
|
||||||
| `LO` | Current user's location |
|
| `LO` | Current user's location |
|
||||||
| `UA` | Current user's age |
|
| `UA` | Current user's age |
|
||||||
| `BD` | Current user's birthday (using theme date format) |
|
| `BD` | Current user's birthday (using theme date format) |
|
||||||
|
|
Loading…
Reference in New Issue