mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Squashed commit of the following:
commitcc6a35e61dAuthor: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 17:27:50 2025 -0600 fix(CSP): more Amazon domains commit985b86c29aAuthor: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 17:18:08 2025 -0600 fix(csp): more loggly allowance commit166bd31527Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 17:12:00 2025 -0600 fix(csp): data, inline, some refactoring commit1a0a6c1806Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 17:05:44 2025 -0600 fix(CSP): override default script-src commit023d9886c8Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 16:56:24 2025 -0600 fix(CSP): unsafe-eval in default-src commitf51f0a0c93Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 16:52:14 2025 -0600 fix(CSP): move trusted list to default-src commit83b2ba7688Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 16:38:05 2025 -0600 fix(CSP): explicit habitica/aws in script-src commitd5ca5172d5Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 16:31:38 2025 -0600 fix(CSP): need escaped single quotes commitc677a1ffefAuthor: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 16:27:46 2025 -0600 fix(CSP): unsafe-eval commit6ef35c3f72Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 16:15:07 2025 -0600 fix(CSP): might need to skip entirely in dev but try no 'self' commit5759fb37d8Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 12 15:51:26 2025 -0600 fix(csp): permit AWS in default-src commit9f238abf93Author: Kalista Payne <kalista@habitica.com> Date: Fri Dec 5 17:22:25 2025 -0600 fix(csp): update helmet version to latest commit9462e90f4fAuthor: Kalista Payne <kalista@habitica.com> Date: Tue Nov 25 09:27:05 2025 -0600 feat(security): implement CSP commit72539f9ba3Author: Kalista Payne <kalista@habitica.com> Date: Wed Dec 10 14:16:53 2025 -0600 5.42.2 commitdabd466719Author: Kalista Payne <kalista@habitica.com> Date: Wed Dec 10 14:16:48 2025 -0600 Revert "Chat optimization (#15545)" This reverts commit2917955ef0. commit8bf2304330Author: Kalista Payne <kalista@habitica.com> Date: Wed Dec 10 14:15:48 2025 -0600 chore(event): G1G1 date tweaks commit6937dc4e4eAuthor: Kalista Payne <kalista@habitica.com> Date: Mon Dec 8 16:37:04 2025 -0600 fix(subscription): couple more layout tweaks
This commit is contained in:
@@ -2,7 +2,6 @@ import mongoose from 'mongoose';
|
||||
import get from 'lodash/get';
|
||||
import sinon from 'sinon';
|
||||
import moment from 'moment';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import ensureDevelopmentMode from '../../middlewares/ensureDevelopmentMode';
|
||||
import ensureTimeTravelMode from '../../middlewares/ensureTimeTravelMode';
|
||||
@@ -12,7 +11,6 @@ import {
|
||||
model as Group,
|
||||
// basicFields as basicGroupFields,
|
||||
} from '../../models/group';
|
||||
import { chatModel as Chat, inboxModel as Inbox } from '../../models/message';
|
||||
import connectToMongoDB from '../../libs/mongoose';
|
||||
|
||||
const { content } = common;
|
||||
@@ -313,93 +311,4 @@ api.timeTravelAdjust = {
|
||||
},
|
||||
};
|
||||
|
||||
api.seedPartyChat = {
|
||||
method: 'POST',
|
||||
url: '/debug/seed-party-chat',
|
||||
middlewares: [ensureDevelopmentMode, authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
const { user } = res.locals;
|
||||
const messageCount = Number(req.body.messageCount);
|
||||
|
||||
if (!Number.isInteger(messageCount) || messageCount < 1) {
|
||||
throw new BadRequest('messageCount must be a positive integer.');
|
||||
}
|
||||
|
||||
if (!user.party._id) {
|
||||
throw new BadRequest('You are not in a party.');
|
||||
}
|
||||
|
||||
const party = await Group.findOne({ _id: user.party._id, type: 'party' }).exec();
|
||||
if (!party) {
|
||||
throw new BadRequest('Party not found.');
|
||||
}
|
||||
|
||||
const messages = [];
|
||||
const baseTimestamp = Date.now();
|
||||
|
||||
for (let i = 1; i <= messageCount; i += 1) {
|
||||
const id = uuid();
|
||||
messages.push({
|
||||
_id: id,
|
||||
id,
|
||||
groupId: party._id,
|
||||
text: `#${i}`,
|
||||
unformattedText: `#${i}`,
|
||||
timestamp: new Date(baseTimestamp - (messageCount - i) * 1000),
|
||||
likes: {},
|
||||
flags: {},
|
||||
flagCount: 0,
|
||||
uuid: 'system',
|
||||
user: 'System',
|
||||
client: 'debug-seed',
|
||||
});
|
||||
}
|
||||
|
||||
await Chat.insertMany(messages);
|
||||
|
||||
res.respond(200, { messageCount });
|
||||
},
|
||||
};
|
||||
|
||||
// Messaging ourselves for testing
|
||||
api.seedInbox = {
|
||||
method: 'POST',
|
||||
url: '/debug/seed-inbox',
|
||||
middlewares: [ensureDevelopmentMode, authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
const { user } = res.locals;
|
||||
const messageCount = Number(req.body.messageCount);
|
||||
|
||||
if (!Number.isInteger(messageCount) || messageCount < 1) {
|
||||
throw new BadRequest('messageCount must be a positive integer.');
|
||||
}
|
||||
|
||||
const messages = [];
|
||||
const baseTimestamp = Date.now();
|
||||
|
||||
for (let i = 1; i <= messageCount; i += 1) {
|
||||
const id = uuid();
|
||||
messages.push({
|
||||
_id: id,
|
||||
id,
|
||||
ownerId: user._id,
|
||||
uuid: user._id,
|
||||
user: user.profile.name,
|
||||
text: `#${i}`,
|
||||
unformattedText: `#${i}`,
|
||||
timestamp: new Date(baseTimestamp - (messageCount - i) * 1000),
|
||||
likes: {},
|
||||
flags: {},
|
||||
flagCount: 0,
|
||||
sent: true,
|
||||
client: 'debug-seed',
|
||||
});
|
||||
}
|
||||
|
||||
await Inbox.insertMany(messages);
|
||||
|
||||
res.respond(200, { messageCount });
|
||||
},
|
||||
};
|
||||
|
||||
export default api;
|
||||
|
||||
Reference in New Issue
Block a user