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:
@@ -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();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user