Merge branch 'user-auto-signature' of ssh://numinibsd/git/base/enigma-bbs into 0.0.10-alpha
This commit is contained in:
commit
c476d366c7
|
@ -2,11 +2,13 @@
|
|||
*.pem
|
||||
|
||||
# Various directories
|
||||
config/config.hjson
|
||||
logs/
|
||||
config/
|
||||
db/
|
||||
dropfiles/
|
||||
drop/
|
||||
file_base/
|
||||
logs/
|
||||
mail/
|
||||
node_modules/
|
||||
docs/_site/
|
||||
docs/.sass-cache/
|
||||
`
|
||||
.vscode/
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -447,6 +447,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
editAutoSignature: {
|
||||
0: {
|
||||
mci: {
|
||||
MT1: {
|
||||
height: 8
|
||||
width: 73
|
||||
}
|
||||
BT2: {
|
||||
focusTextStyle: upper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messageSearch: {
|
||||
0: {
|
||||
mci: {
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const { MenuModule } = require('./menu_module.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
const _ = require('lodash');
|
||||
|
||||
exports.moduleInfo = {
|
||||
name : 'User Auto-Sig Editor',
|
||||
desc : 'Module for editing auto-sigs',
|
||||
author : 'NuSkooler',
|
||||
};
|
||||
|
||||
const FormIds = {
|
||||
edit : 0,
|
||||
};
|
||||
|
||||
const MciViewIds = {
|
||||
editor : 1,
|
||||
save : 2,
|
||||
};
|
||||
|
||||
exports.getModule = class UserAutoSigEditorModule extends MenuModule {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.config = Object.assign({}, _.get(options, 'menuConfig.config'), { extraArgs : options.extraArgs });
|
||||
|
||||
this.menuMethods = {
|
||||
saveChanges : (formData, extraArgs, cb) => {
|
||||
return this.saveChanges(cb);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
mciReady(mciData, cb) {
|
||||
super.mciReady(mciData, err => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
async.series(
|
||||
[
|
||||
(callback) => {
|
||||
return this.prepViewController('edit', FormIds.edit, mciData.menu, callback);
|
||||
},
|
||||
(callback) => {
|
||||
const requiredCodes = [ MciViewIds.editor, MciViewIds.save ];
|
||||
return this.validateMCIByViewIds('edit', requiredCodes, callback);
|
||||
},
|
||||
(callback) => {
|
||||
const sig = this.client.user.getProperty(UserProps.AutoSignature) || '';
|
||||
this.setViewText('edit', MciViewIds.editor, sig);
|
||||
return callback(null);
|
||||
}
|
||||
],
|
||||
err => {
|
||||
return cb(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
saveChanges(cb) {
|
||||
const sig = this.getView('edit', MciViewIds.editor).getData().trim();
|
||||
this.client.user.persistProperty(UserProps.AutoSignature, sig, err => {
|
||||
if(err) {
|
||||
this.client.log.error( { error : err.message }, 'Could not save auto-sig');
|
||||
}
|
||||
return this.prevMenu(cb);
|
||||
});
|
||||
}
|
||||
};
|
21
core/fse.js
21
core/fse.js
|
@ -325,20 +325,21 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
|||
|
||||
buildMessage(cb) {
|
||||
const headerValues = this.viewControllers.header.getFormData().value;
|
||||
const area = getMessageAreaByTag(this.messageAreaTag);
|
||||
|
||||
const getFromUserName = () => {
|
||||
const area = getMessageAreaByTag(this.messageAreaTag);
|
||||
return (area && area.realNames) ?
|
||||
this.client.user.getProperty(UserProps.RealName) || this.client.user.username :
|
||||
this.client.user.username;
|
||||
};
|
||||
|
||||
let messageBody = this.viewControllers.body.getView(MciViewIds.body.message).getData( { forceLineTerms : this.replyIsAnsi } );
|
||||
|
||||
const msgOpts = {
|
||||
areaTag : this.messageAreaTag,
|
||||
toUserName : headerValues.to,
|
||||
fromUserName : getFromUserName(),
|
||||
subject : headerValues.subject,
|
||||
message : this.viewControllers.body.getView(MciViewIds.body.message).getData( { forceLineTerms : this.replyIsAnsi } ),
|
||||
};
|
||||
|
||||
if(this.isReply()) {
|
||||
|
@ -351,11 +352,23 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
|||
// to packetAnsiMsgEncoding (generally cp437) as various boards
|
||||
// really don't like ANSI messages in UTF-8 encoding (they should!)
|
||||
//
|
||||
msgOpts.meta = { System : { 'explicit_encoding' : _.get(Config(), 'scannerTossers.ftn_bso.packetAnsiMsgEncoding', 'cp437') } };
|
||||
msgOpts.message = `${ansi.reset()}${ansi.eraseData(2)}${ansi.goto(1,1)}\r\n${ansi.up()}${msgOpts.message}`;
|
||||
msgOpts.meta = { System : { 'explicit_encoding' : _.get(Config(), 'scannerTossers.ftn_bso.packetAnsiMsgEncoding', 'cp437') } };
|
||||
messageBody = `${ansi.reset()}${ansi.eraseData(2)}${ansi.goto(1,1)}\r\n${ansi.up()}${messageBody}`;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Append auto-signature, if enabled for the area & the user has one
|
||||
//
|
||||
if(false != area.autoSignatures) {
|
||||
const sig = this.client.user.getProperty(UserProps.AutoSignature);
|
||||
if(sig) {
|
||||
messageBody += `\r\n-- \r\n${sig}`;
|
||||
}
|
||||
}
|
||||
|
||||
// finally, create the message
|
||||
msgOpts.message = messageBody;
|
||||
this.message = new Message(msgOpts);
|
||||
|
||||
return cb(null);
|
||||
|
|
|
@ -27,6 +27,7 @@ module.exports = {
|
|||
LastLoginTs : 'last_login_timestamp',
|
||||
LoginCount : 'login_count',
|
||||
UserComment : 'user_comment', // NYI
|
||||
AutoSignature : 'auto_signature',
|
||||
|
||||
DownloadQueue : 'dl_queue', // download_queue.js
|
||||
|
||||
|
|
|
@ -2090,6 +2090,10 @@
|
|||
value: { command: "S" }
|
||||
action: @menu:messageSearch
|
||||
}
|
||||
{
|
||||
value: { command: "A" }
|
||||
action: @menu:editAutoSignature
|
||||
}
|
||||
{
|
||||
value: 1
|
||||
action: @menu:messageArea
|
||||
|
@ -2097,6 +2101,42 @@
|
|||
]
|
||||
}
|
||||
|
||||
editAutoSignature: {
|
||||
desc: Auto Sig Editor
|
||||
module: autosig_edit
|
||||
art: autosig
|
||||
form: {
|
||||
0: {
|
||||
mci: {
|
||||
MT1: {
|
||||
argName: signature
|
||||
tabSwitchesView: true
|
||||
}
|
||||
BT2: {
|
||||
text: save
|
||||
argName: save
|
||||
submit: true
|
||||
}
|
||||
}
|
||||
submit: {
|
||||
*: [
|
||||
{
|
||||
value: { save: null }
|
||||
action: @method:saveChanges
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
actionKeys: [
|
||||
{
|
||||
keys: [ "escape" ]
|
||||
action: @systemMethod:prevMenu
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messageSearch: {
|
||||
desc: Message Search
|
||||
module: message_base_search
|
||||
|
|
Loading…
Reference in New Issue