2015-08-14 20:49:06 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
const FullScreenEditorModule = require('./fse.js').FullScreenEditorModule;
|
|
|
|
const persistMessage = require('./message_area.js').persistMessage;
|
|
|
|
const UserProps = require('./user_property.js');
|
|
|
|
const { hasMessageConfAndAreaWrite } = require('./message_area.js');
|
2015-08-16 19:35:34 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
const async = require('async');
|
2015-08-14 20:49:06 +00:00
|
|
|
|
|
|
|
exports.moduleInfo = {
|
2022-06-05 20:04:25 +00:00
|
|
|
name: 'Message Area Post',
|
|
|
|
desc: 'Module for posting a new message to an area',
|
|
|
|
author: 'NuSkooler',
|
2015-08-14 20:49:06 +00:00
|
|
|
};
|
|
|
|
|
2023-09-26 01:25:01 +00:00
|
|
|
const MciViewIds = {
|
|
|
|
header: {
|
|
|
|
from: 1,
|
|
|
|
to: 2,
|
|
|
|
subject: 3,
|
|
|
|
errorMsg: 4,
|
|
|
|
modTimestamp: 5,
|
|
|
|
msgNum: 6,
|
|
|
|
msgTotal: 7,
|
|
|
|
|
|
|
|
customRangeStart: 10, // 10+ = customs
|
|
|
|
},
|
|
|
|
|
|
|
|
body: {
|
|
|
|
message: 1,
|
|
|
|
},
|
|
|
|
|
|
|
|
// :TODO: quote builder MCIs - remove all magic #'s
|
|
|
|
|
|
|
|
// :TODO: consolidate all footer MCI's - remove all magic #'s
|
|
|
|
ViewModeFooter: {
|
|
|
|
MsgNum: 6,
|
|
|
|
MsgTotal: 7,
|
|
|
|
// :TODO: Just use custom ranges
|
|
|
|
},
|
|
|
|
|
|
|
|
quoteBuilder: {
|
|
|
|
quotedMsg: 1,
|
|
|
|
// 2 NYI
|
|
|
|
quoteLines: 3,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
|
2018-06-22 05:15:04 +00:00
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
2015-08-14 20:49:06 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
const self = this;
|
2015-08-16 19:35:34 +00:00
|
|
|
|
2018-06-23 03:26:46 +00:00
|
|
|
// we're posting, so always start with 'edit' mode
|
2018-06-22 05:15:04 +00:00
|
|
|
this.editorMode = 'edit';
|
2015-08-14 20:49:06 +00:00
|
|
|
|
2022-06-05 20:04:25 +00:00
|
|
|
this.menuMethods.editModeMenuSave = function (formData, extraArgs, cb) {
|
2018-06-22 05:15:04 +00:00
|
|
|
var msg;
|
|
|
|
async.series(
|
|
|
|
[
|
|
|
|
function getMessageObject(callback) {
|
|
|
|
self.getMessage(function gotMsg(err, msgObj) {
|
|
|
|
msg = msgObj;
|
|
|
|
return callback(err);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
function saveMessage(callback) {
|
|
|
|
return persistMessage(msg, callback);
|
|
|
|
},
|
|
|
|
function updateStats(callback) {
|
2018-11-28 04:21:00 +00:00
|
|
|
self.updateUserAndSystemStats(callback);
|
2022-06-05 20:04:25 +00:00
|
|
|
},
|
2018-06-22 05:15:04 +00:00
|
|
|
],
|
|
|
|
function complete(err) {
|
2022-06-05 20:04:25 +00:00
|
|
|
if (err) {
|
2023-09-26 01:25:01 +00:00
|
|
|
const errMsgView = self.viewControllers.header.getView(
|
|
|
|
MciViewIds.header.errorMsg
|
2018-06-22 05:15:04 +00:00
|
|
|
);
|
2023-09-26 01:25:01 +00:00
|
|
|
if (errMsgView) {
|
|
|
|
errMsgView.setText(err.message);
|
|
|
|
}
|
|
|
|
return cb(err);
|
2018-06-22 05:15:04 +00:00
|
|
|
}
|
2018-01-15 19:22:11 +00:00
|
|
|
|
2023-09-26 01:25:01 +00:00
|
|
|
// note: not logging 'from' here as it's part of client.log.xxxx()
|
|
|
|
self.client.log.info(
|
|
|
|
{
|
|
|
|
to: msg.toUserName,
|
|
|
|
subject: msg.subject,
|
|
|
|
uuid: msg.messageUuid,
|
|
|
|
},
|
|
|
|
`User "${self.client.user.username}" posted message to "${msg.toUserName}" (${msg.areaTag})`
|
|
|
|
);
|
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
return self.nextMenu(cb);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
2015-08-14 20:49:06 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
enter() {
|
2019-09-17 04:05:03 +00:00
|
|
|
this.messageAreaTag =
|
2022-06-05 20:04:25 +00:00
|
|
|
this.messageAreaTag || this.client.user.getProperty(UserProps.MessageAreaTag);
|
2015-08-18 03:45:11 +00:00
|
|
|
|
2018-06-22 05:15:04 +00:00
|
|
|
super.enter();
|
|
|
|
}
|
2019-09-17 04:05:03 +00:00
|
|
|
|
|
|
|
initSequence() {
|
2022-06-05 20:04:25 +00:00
|
|
|
if (!hasMessageConfAndAreaWrite(this.client, this.messageAreaTag)) {
|
2019-09-17 04:05:03 +00:00
|
|
|
const noAcsMenu =
|
|
|
|
this.menuConfig.config.messageBasePostMessageNoAccess ||
|
|
|
|
'messageBasePostMessageNoAccess';
|
|
|
|
|
|
|
|
return this.gotoMenuOrShowMessage(
|
|
|
|
noAcsMenu,
|
2020-06-16 01:08:55 +00:00
|
|
|
'You do not have the proper access to post here!'
|
2019-09-17 04:05:03 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
super.initSequence();
|
|
|
|
}
|
2022-06-05 20:04:25 +00:00
|
|
|
};
|