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
2
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 2.1.3 to 2.1.4

34

lib/config.js

@@ -0,3 +1,7 @@

/* eslint-disable no-await-in-loop */
'use strict';
const _ = require('lodash');
const packageInfo = require('../package.json');

@@ -79,2 +83,32 @@ const pluginInfo = require('../plugin.json');

},
getRandomUser: async function (socket, data) {
let done = false;
let start = -49;
let stop = start + 48;
const oneMinuteMs = 60 * 1000;
const cutoffMinutes = parseInt(data.cutoffMinutes, 10) || 30;
const cutoff = Date.now() - (cutoffMinutes * oneMinuteMs);
const foundShouts = [];
do {
const sids = await NodeBB.db.getListRange('shouts', start, stop);
if (!sids.length) {
done = true;
} else {
const allShouts = await NodeBB.db.getObjects(sids.map(sid => `shout:${sid}`));
const shouts = allShouts.filter(s => s && s.timestamp >= cutoff);
const allBeforeCutoff = allShouts.every(s => s && s.timestamp < cutoff);
if (allBeforeCutoff) {
done = true;
}
foundShouts.push(...shouts);
}
start -= 50;
stop = start + 49;
} while (!done);
if (!foundShouts.length) {
throw new Error(`No users found in the past ${cutoffMinutes} minutes`);
}
const randomUid = _.sample(_.uniq(foundShouts.map(s => s.fromuid)));
return await NodeBB.User.getUserFields(randomUid, ['uid', 'username', 'userslug', 'picture']);
},
};

@@ -81,0 +115,0 @@

6

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

@@ -24,3 +24,5 @@ "main": "library.js",

},
"dependencies": {},
"dependencies": {
"lodash": "^4.17.21"
},
"devDependencies": {

@@ -27,0 +29,0 @@ "eslint": "7.32.0",

@@ -54,2 +54,13 @@ 'use strict';

}
$('[component="shoutbox/random-user"]').on('click', function () {
const cutoff = $(this).attr('data-cutoff');
socket.emit('admin.plugins.shoutbox.getRandomUser', { cutoffMinutes: cutoff }, async function (err, user) {
if (err) {
return Shoutbox.alert('error', err);
}
const bootbox = await app.require('bootbox');
bootbox.alert(`Picked user <a href="${config.relative_path}/user/${user.userslug}">${user.username}</a>`);
});
});
};

@@ -56,0 +67,0 @@

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