Testing #307
1 changed files with 13 additions and 8 deletions
|
@ -57,20 +57,25 @@ module.exports = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
parsePublishApiChannel ({channelName, channelPassword}, user) {
|
parsePublishApiChannel ({channelName, channelPassword}, user) {
|
||||||
// anonymous if no channel name provided
|
// if no channel name provided, publish will be anonymous
|
||||||
let anonymous = (channelName === null || channelName === undefined || channelName === '');
|
// if a channel name is provided...
|
||||||
// if a channel name is provided, get password from the user token
|
|
||||||
if (user) {
|
|
||||||
channelPassword = user.channelPassword;
|
|
||||||
} ;
|
|
||||||
// cleanse channel name
|
|
||||||
if (channelName) {
|
if (channelName) {
|
||||||
|
// make sure a password was provided
|
||||||
|
if (!channelPassword) {
|
||||||
|
throw new Error('Channel name provided without password');
|
||||||
|
}
|
||||||
|
// if request comes from the client and is logged in
|
||||||
|
// ensure it is the same channel and get the password
|
||||||
|
if (user) {
|
||||||
|
channelName = user.channelName;
|
||||||
|
channelPassword = user.channelPassword;
|
||||||
|
} ;
|
||||||
|
// add the @ if the channel name is missing it
|
||||||
if (channelName.indexOf('@') !== 0) {
|
if (channelName.indexOf('@') !== 0) {
|
||||||
channelName = `@${channelName}`;
|
channelName = `@${channelName}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
anonymous,
|
|
||||||
channelName,
|
channelName,
|
||||||
channelPassword,
|
channelPassword,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue