Use 33 characters admin channels
parent
807642151a
commit
dbce0fe429
|
@ -255,7 +255,7 @@ Channel.writePrivateMessage = function (Env, args, _cb, Server, netfluxId) {
|
|||
var allowed = HK.listAllowedUsers(metadata);
|
||||
|
||||
// Special broadcast channel
|
||||
if (channelId === '00000000000000000000000000000000') {
|
||||
if (channelId.length === HK.ADMIN_CHANNEL_LENGTH) {
|
||||
allowed = Env.admins;
|
||||
}
|
||||
|
||||
|
@ -283,12 +283,19 @@ Channel.writePrivateMessage = function (Env, args, _cb, Server, netfluxId) {
|
|||
|
||||
// historyKeeper already knows how to handle metadata and message validation, so we just pass it off here
|
||||
// if the message isn't valid it won't be stored.
|
||||
Env.historyKeeper.channelMessage(Server, channelStruct, fullMessage);
|
||||
Env.historyKeeper.channelMessage(Server, channelStruct, fullMessage, function (err) {
|
||||
if (err) {
|
||||
// Message not stored...
|
||||
return void cb(err);
|
||||
}
|
||||
|
||||
Server.getChannelUserList(channelId).forEach(function (userId) {
|
||||
Server.send(userId, fullMessage);
|
||||
// Broadcast the message
|
||||
Server.getChannelUserList(channelId).forEach(function (userId) {
|
||||
Server.send(userId, fullMessage);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -34,6 +34,7 @@ const getHash = HK.getHash = function (msg, Log) {
|
|||
// historyKeeper should explicitly store any channel
|
||||
// with a 32 character id
|
||||
const STANDARD_CHANNEL_LENGTH = HK.STANDARD_CHANNEL_LENGTH = 32;
|
||||
const ADMIN_CHANNEL_LENGTH = HK.ADMIN_CHANNEL_LENGTH = 33;
|
||||
|
||||
// historyKeeper should not store messages sent to any channel
|
||||
// with a 34 character id
|
||||
|
@ -883,7 +884,8 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) {
|
|||
// don't store messages if the channel id indicates that it's an ephemeral message
|
||||
if (!channel.id || channel.id.length === EPHEMERAL_CHANNEL_LENGTH) { return void cb(); }
|
||||
|
||||
if (channel.id === '00000000000000000000000000000000' && msgStruct[1] !== null) {
|
||||
// Admin channel. We can only write to this one from private message (RPC)
|
||||
if (channel.id.length === ADMIN_CHANNEL_LENGTH && msgStruct[1] !== null) {
|
||||
return void cb('ERESTRICTED_ADMIN');
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ define([
|
|||
var BLOCKING_TYPES = [
|
||||
];
|
||||
|
||||
var BROADCAST_CHAN = '00000000000000000000000000000000';
|
||||
var BROADCAST_CHAN = '000000000000000000000000000000000'; // Admin channel, 33 characters
|
||||
|
||||
var initializeMailboxes = function (ctx, mailboxes) {
|
||||
if (!mailboxes['notifications'] && ctx.loggedIn) {
|
||||
|
@ -44,6 +44,12 @@ define([
|
|||
if (res.error) { console.error(res); }
|
||||
});
|
||||
}
|
||||
|
||||
// XXX Debugging code to remove deprecated dev data
|
||||
if (mailboxes.broadcast && mailboxes.broacast.channel && mailboxes.broadcast.channel.length === 32) {
|
||||
delete mailboxes['broadcast'];
|
||||
}
|
||||
|
||||
if (!mailboxes['broadcast']) {
|
||||
mailboxes.broadcast = {
|
||||
channel: BROADCAST_CHAN,
|
||||
|
|
Loading…
Reference in New Issue