New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nodebb-plugin-shoutbox

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodebb-plugin-shoutbox - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

50

library.js

@@ -187,4 +187,31 @@ var async = require('async'),

"remove": function(socket, data, callback) {
Shoutbox.backend.removeShout(data.sid, socket.uid, callback);
if (typeof(data.sid) === 'string') {
Shoutbox.backend.removeShout(data.sid, socket.uid, function(err, result) {
if (result === true) {
SocketIndex.server.sockets.in('global').emit('event:shoutbox.delete', {
'id': '#shoutbox-shout-' + data.sid
});
}
callback(err, result);
});
}
},
"edit": function(socket, data, callback) {
console.log(data);
console.log(typeof(data.sid));
if (typeof(data.sid) === 'string' && typeof(data.user) === 'string') {
var msg = S(data.edited).stripTags().s;
Shoutbox.backend.editShout(data.sid, msg, socket.uid, data.user, function(err, result) {
console.log(result);
if (result !== false) {
SocketIndex.server.sockets.in('global').emit('event:shoutbox.edit', {
'id': '#shoutbox-shout-' + data.sid,
'content': result
});
result = true;
}
callback(err, result);
});
}
},
"removeAll": function(socket, data, callback) {

@@ -316,2 +343,23 @@ if (data !== null && data !== undefined) {

},
"editShout": function(sid, msg, uid, username, callback) {
User.isAdministrator(uid, function(err, isAdmin) {
db.getObjectField('shout:' + sid, 'fromuid', function(err, fromuid) {
if (err) {
return callback("Unknown error", false);
}
if (fromuid === uid || isAdmin) {
db.setObjectField('shout:' + sid, 'content', msg, function (err, result) {
if (err) {
return callback("Unknown error", false);
}
Shoutbox.backend.parse(uid, username, msg, function(err, result) {
return callback(null, result);
});
});
} else {
return callback("Shout does not belong to you", false);
}
});
});
},
"pruneDeleted": function(uid, callback) {

@@ -318,0 +366,0 @@ User.isAdministrator(uid, function(err, isAdmin) {

2

package.json
{
"name": "nodebb-plugin-shoutbox",
"version": "0.0.4",
"version": "0.0.5",
"description": "NodeBB Shoutbox Plugin",

@@ -5,0 +5,0 @@ "main": "library.js",

@@ -16,7 +16,11 @@ define(['string'], function(S) {

"remove" : "modules.shoutbox.remove",
"edit": "modules.shoutbox.edit",
"get_users": "modules.shoutbox.get_users",
"receive": "event:shoutbox.receive"
"onreceive": "event:shoutbox.receive",
"ondelete": "event:shoutbox.delete",
"onedit": "event:shoutbox.edit"
},
"titleAlert": "[ %u ] - new shout!",
"anonMessage": "You must be logged in to view the shoutbox!"
"anonMessage": "You must be logged in to view the shoutbox!",
"emptyMessage": "The shoutbox is empty, start shouting!"
};

@@ -65,2 +69,5 @@

var shoutContent = shoutBox.find('#shoutbox-content');
if (shoutContent.find('div[id^="shoutbox-shout"]').length === 0) {
shoutContent.html('');
}
shoutContent.append(box.base.parseShout(shout));

@@ -75,4 +82,8 @@ box.base.scrollToBottom(shoutContent);

socket.emit(box.vars.sockets.get, function(err, shouts) {
for(var i = 0; i<shouts.length; ++i) {
module.box.addShout(shoutBox, shouts[i]);
if (shouts.length === 0) {
box.utils.showEmptyMessage(shoutBox);
} else {
for(var i = 0; i<shouts.length; ++i) {
module.box.addShout(shoutBox, shouts[i]);
}
}

@@ -86,5 +97,7 @@ });

if (shout.fromuid === app.uid || box.vars.config.isAdmin === true) {
options = '<button type="button" class="close pull-right" aria-hidden="true">&times;</button>';
options += '<button type="button" class="shoutbox-shout-option shoutbox-shout-option-close close pull-right fa fa-times" aria-hidden="true"></button>';
options += '<button type="button" class="shoutbox-shout-option shoutbox-shout-option-edit close pull-right fa fa-pencil" aria-hidden="true"></button>';
}
return "<div id='shoutbox-shout-" + shout.sid + "'>" + options + S(prefix + shout.content).stripTags('p').s + "</div>";
var content = '<span class="shoutbox-shout-content">' + shout.content + '</span>';
return "<div id='shoutbox-shout-" + shout.sid + "'>" + options + S(prefix + content).stripTags('p').s + "</div>";
},

@@ -121,2 +134,5 @@ "scrollToBottom": function(shoutContent) {

},
"showEmptyMessage": function(shoutBox) {
shoutBox.find('#shoutbox-content').html(box.vars.emptyMessage);
},
"getConfig": function() {

@@ -184,10 +200,9 @@ socket.emit('modules.shoutbox.getConfig', function(err, config) {

"register": function(shoutBox) {
shoutBox.off('click', 'button.close').on('click', 'button.close', this.handle);
shoutBox.off('click', '.shoutbox-shout-option-close').on('click', '.shoutbox-shout-option-close', this.handle);
},
"handle": function(e) {
var sid = e.currentTarget.parentNode.id.match(/\d+/),
node = e.currentTarget.parentNode;
var sid = e.currentTarget.parentNode.id.match(/\d+/)[0];
socket.emit(box.vars.sockets.remove, {"sid": sid}, function (err, result) {
if (result === true) {
node.remove();
app.alertSuccess("Successfully deleted shout!");
} else if (err) {

@@ -199,2 +214,25 @@ app.alertError("Error deleting shout: " + err, 3000);

},
"edit": {
"register": function(shoutBox) {
shoutBox.off('click', '.shoutbox-shout-option-edit').on('click', '.shoutbox-shout-option-edit', this.handle);
},
"handle": function(e) {
var shout = e.currentTarget.parentNode,
sid = shout.id.match(/\d+/)[0],
user = $(shout).find('span[class^="shoutbox-user"]').text(),
cur = $(shout).find('.shoutbox-shout-content').html().split(': ')[1];
bootbox.prompt("Enter edited message", function(result) {
if (result === cur || result === null) {
return;
}
socket.emit(box.vars.sockets.edit, {"sid": sid, "user": user, "edited": result}, function (err, result) {
if (result === true) {
app.alertSuccess("Successfully edited shout!");
} else if (err) {
app.alertError("Error editing shout: " + err, 3000);
}
});
}).find('.bootbox-input').val(cur);
}
},
"gist": {

@@ -325,6 +363,6 @@ "register": function(shoutBox) {

box.sockets = {
"receive": {
"onreceive": {
"register": function() {
if (socket.listeners(box.vars.sockets.receive).length === 0) {
socket.on(box.vars.sockets.receive, this.handle);
if (socket.listeners(box.vars.sockets.onreceive).length === 0) {
socket.on(box.vars.sockets.onreceive, this.handle);
}

@@ -338,2 +376,22 @@ },

}
},
"ondelete": {
"register": function() {
if (socket.listeners(box.vars.sockets.ondelete).length === 0) {
socket.on(box.vars.sockets.ondelete, this.handle);
}
},
"handle": function(data) {
$(data.id).remove();
}
},
"onedit": {
"register": function() {
if (socket.listeners(box.vars.sockets.onedit).length === 0) {
socket.on(box.vars.sockets.onedit, this.handle);
}
},
"handle": function(data) {
$(data.id).find('.shoutbox-shout-content').html('*' + S(data.content).stripTags('p').s);
}
}

@@ -340,0 +398,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc