summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.js6
-rwxr-xr-xroutes.js15
2 files changed, 10 insertions, 11 deletions
diff --git a/activitypub.js b/activitypub.js
index 8ec2ee5..8272b72 100644
--- a/activitypub.js
+++ b/activitypub.js
@@ -7,8 +7,8 @@ const addToLog = require('./helpers.js').addToLog;
const crypto = require('crypto');
// This alphabet (used to generate all event, group, etc. IDs) is missing '-'
// because ActivityPub doesn't like it in IDs
-const nanoid = require('nanoid/generate');
-const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
+const { customAlphabet } = require('nanoid');
+const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_', 21);
var moment = require('moment-timezone');
const mongoose = require('mongoose');
const Event = mongoose.model('Event');
@@ -805,7 +805,7 @@ function _handleCreateNoteComment(req, res) {
if (ourEvents.length === 1) {
let eventID = ourEvents[0];
// add comment
- let commentID = nanoid(alphabet, 21);
+ let commentID = nanoid();
// get the actor for the commenter
request({
url: req.body.actor,
diff --git a/routes.js b/routes.js
index abec8c1..c74416c 100755
--- a/routes.js
+++ b/routes.js
@@ -6,8 +6,8 @@ const mongoose = require('mongoose');
// This alphabet (used to generate all event, group, etc. IDs) is missing '-'
// because ActivityPub doesn't like it in IDs
-const nanoid = require('nanoid/generate');
-const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
+const { customAlphabet } = require('nanoid');
+const nanoid = customAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_', 21);
const randomstring = require("randomstring");
@@ -626,9 +626,8 @@ router.get('/exportevent/:eventID', (req, res) => {
// failureFlash: true })
//);
-
router.post('/newevent', async (req, res) => {
- let eventID = nanoid(alphabet, 21);
+ let eventID = nanoid();
let editToken = randomstring.generate();
let eventImageFilename = "";
let isPartOfEventGroup = false;
@@ -717,7 +716,7 @@ router.post('/newevent', async (req, res) => {
});
router.post('/importevent', (req, res) => {
- let eventID = nanoid(alphabet, 21);
+ let eventID = nanoid();
let editToken = randomstring.generate();
if (req.files && Object.keys(req.files).length !== 0) {
let iCalObject = ical.parseICS(req.files.icsImportControl.data.toString('utf8'));
@@ -788,7 +787,7 @@ router.post('/importevent', (req, res) => {
});
router.post('/neweventgroup', (req, res) => {
- let eventGroupID = nanoid(alphabet, 21);
+ let eventGroupID = nanoid();
let editToken = randomstring.generate();
let eventGroupImageFilename = "";
if (req.files && Object.keys(req.files).length !== 0) {
@@ -1395,7 +1394,7 @@ router.post('/removeattendee/:eventID/:attendeeID', (req, res) => {
});
router.post('/post/comment/:eventID', (req, res) => {
- let commentID = nanoid(alphabet, 21);
+ let commentID = nanoid();
const newComment = {
id: commentID,
author: req.body.commentAuthor,
@@ -1459,7 +1458,7 @@ router.post('/post/comment/:eventID', (req, res) => {
});
router.post('/post/reply/:eventID/:commentID', (req, res) => {
- let replyID = nanoid(alphabet, 21);
+ let replyID = nanoid();
let commentID = req.params.commentID;
const newReply = {
id: replyID,