Add 'write' access for post FSE

+ hasMessageConfAndAreaWrite()
+ MenuModule helpers: gotoMenuOrPrev(), gotoMenuOrShowMessage(). These will likely replace many other pieces of code soon.
This commit is contained in:
Bryan Ashby
2019-09-16 22:05:03 -06:00
parent 7783262af6
commit 1fdaaf5633
3 changed files with 68 additions and 5 deletions

View File

@@ -4,6 +4,9 @@
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');
const _ = require('lodash');
const async = require('async');
@@ -59,12 +62,25 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
}
enter() {
if(_.isString(this.client.user.properties[UserProps.MessageAreaTag]) &&
!_.isString(this.messageAreaTag))
{
this.messageAreaTag = this.client.user.properties[UserProps.MessageAreaTag];
}
this.messageAreaTag =
this.messageAreaTag ||
this.client.user.getProperty(UserProps.MessageAreaTag);
super.enter();
}
initSequence() {
if(!hasMessageConfAndAreaWrite(this.client, this.messageAreaTag)) {
const noAcsMenu =
this.menuConfig.config.messageBasePostMessageNoAccess ||
'messageBasePostMessageNoAccess';
return this.gotoMenuOrShowMessage(
noAcsMenu,
'You do not have the proper access to post here!',
);
}
super.initSequence();
}
};