2015-08-14 20:49:06 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2017-11-24 23:23:15 +00:00
|
|
|
const FullScreenEditorModule = require('./fse.js').FullScreenEditorModule;
|
|
|
|
const persistMessage = require('./message_area.js').persistMessage;
|
2015-08-16 19:35:34 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
const _ = require('lodash');
|
|
|
|
const async = require('async');
|
2015-08-14 20:49:06 +00:00
|
|
|
|
|
|
|
exports.moduleInfo = {
|
|
|
|
name : 'Message Area Post',
|
2015-09-01 05:18:46 +00:00
|
|
|
desc : 'Module for posting a new message to an area',
|
2015-08-14 20:49:06 +00:00
|
|
|
author : 'NuSkooler',
|
|
|
|
};
|
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
|
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
2015-08-14 20:49:06 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
const self = this;
|
2015-08-16 19:35:34 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
// we're posting, so always start with 'edit' mode
|
|
|
|
this.editorMode = 'edit';
|
2015-08-14 20:49:06 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
this.menuMethods.editModeMenuSave = function(formData, extraArgs, cb) {
|
2015-08-20 04:10:18 +00:00
|
|
|
|
2017-01-26 05:18:05 +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) {
|
|
|
|
self.updateUserStats(callback);
|
|
|
|
}
|
|
|
|
],
|
|
|
|
function complete(err) {
|
|
|
|
if(err) {
|
|
|
|
// :TODO:... sooooo now what?
|
|
|
|
} else {
|
|
|
|
// 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.uuid },
|
|
|
|
'Message persisted'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return self.nextMenu(cb);
|
2015-08-20 04:10:18 +00:00
|
|
|
}
|
2017-01-26 05:18:05 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
2015-08-14 20:49:06 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
enter() {
|
|
|
|
if(_.isString(this.client.user.properties.message_area_tag) && !_.isString(this.messageAreaTag)) {
|
|
|
|
this.messageAreaTag = this.client.user.properties.message_area_tag;
|
|
|
|
}
|
2015-08-18 03:45:11 +00:00
|
|
|
|
2017-01-26 05:18:05 +00:00
|
|
|
super.enter();
|
2015-08-20 23:00:35 +00:00
|
|
|
}
|
2017-01-26 05:18:05 +00:00
|
|
|
};
|