Initial auto-signature support
This commit is contained in:
parent
e861607330
commit
8fde4ccd60
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);
|
||||
});
|
||||
}
|
||||
};
|
16
core/fse.js
16
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()) {
|
||||
|
@ -352,10 +353,19 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
|||
// 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}`;
|
||||
messageBody = `${ansi.reset()}${ansi.eraseData(2)}${ansi.goto(1,1)}\r\n${ansi.up()}${messageBody}`;
|
||||
}
|
||||
}
|
||||
|
||||
if(false != area.autoSignatures) {
|
||||
const sig = this.client.user.getProperty(UserProps.AutoSignature);
|
||||
if(sig) {
|
||||
messageBody += `\r\n-- \r\n${sig}`;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue