mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Improvements and fixes for push notifications (#11507)
* Strip markdown from push notifications
* Revert "Strip markdown from push notifications"
This reverts commit 4741e584c6.
* correctly set type for mention push notifications
* Add unformattedText field to chat messages
* fiix lint errors
* Add check that markdown formatting is stripped from messages
* Add check for markdown formatting in messages.
This commit is contained in:
committed by
Matteo Pagliazzi
parent
3c394e7448
commit
b108b047cd
@@ -1,12 +1,14 @@
|
||||
import mongoose from 'mongoose';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { defaults } from 'lodash';
|
||||
import removeMd from 'remove-markdown';
|
||||
import baseModel from '../libs/baseModel';
|
||||
|
||||
const defaultSchema = () => ({
|
||||
id: String,
|
||||
timestamp: Date,
|
||||
text: String,
|
||||
unformattedText: String,
|
||||
info: { $type: mongoose.Schema.Types.Mixed },
|
||||
|
||||
// sender properties
|
||||
@@ -110,10 +112,12 @@ export function setUserStyles (newMessage, user) {
|
||||
|
||||
export function messageDefaults (msg, user, client, flagCount = 0, info = {}) {
|
||||
const id = uuid();
|
||||
const trimmedMessage = msg.substring(0, 3000);
|
||||
const message = {
|
||||
id,
|
||||
_id: id,
|
||||
text: msg.substring(0, 3000),
|
||||
text: trimmedMessage,
|
||||
unformattedText: removeMd(trimmedMessage),
|
||||
info,
|
||||
timestamp: Number(new Date()),
|
||||
likes: {},
|
||||
|
||||
Reference in New Issue
Block a user