Anonymous posting setup in src
[KisSync.git] / src / channel / anonymouspost.js
blobb5618e57f8bafca2fae7e7a7b6889b97ae482fe3
1 "use strict";
3 var ChannelModule = require("./module");
4 var Flags = require("../flags");
6 function makeid() {
7   var text = "";
8   var possible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
10   for (var i = 0; i < 3; i++)
11     text += possible.charAt(Math.floor(Math.random() * possible.length));
13   return text;
16 console.log(makeid());
18 function AnonymousPost(_channel) {
19     ChannelModule.apply(this, arguments);
22 AnonymousPost.prototype = Object.create(ChannelModule.prototype);
24 AnonymousPost.prototype.onUserPreJoin = function (user, data, cb) {
25     const opts = this.channel.modules.options;
26     var anonymousPosting = opts.get("allow_anon_chat");
27         if(anonymousPosting && user.isAnonymous){
28                 user.guestLogin("Anonymous-" + makeid() +"");
29                 //user.guestLogin("Anonymous");
30                 cb(null, ChannelModule.PASSTHROUGH);
31         }
32         else{
33                 cb(null, ChannelModule.PASSTHROUGH);
34         }
37 module.exports = AnonymousPost;
38 //# sourceMappingURL=anonymouspost.js.map