Notifications v2 and Bailey API (#9716)
* Added initial bailey api
* wip
* implement new panel header
* Fixed lint
* add ability to mark notification as seen
* add notification count, remove top badge from user and add ability to mark multiple notifications as seen
* add support dismissall and mark all as read
* do not dismiss actionable notif
* mark as seen when menu is opened instead of closed
* implement ordering, list of actionable notifications
* add groups messages and fix badges count
* add notifications for received cards
* send card received notification to target not sender
* rename notificaion field
* fix integration tests
* mark cards notifications as read and update tests
* add mystery items notifications
* add unallocated stats points notifications
* fix linting
* simplify code
* refactoring and fixes
* fix dropdown opening
* start splitting notifications into their own component
* add notifications for inbox messages
* fix unit tests
* fix default buttons styles
* add initial bailey support
* add title and tests to new stuff notification
* add notification if a group task needs more work
* add tests and fixes for marking a task as needing more work
* make sure user._v is updated
* remove console.log
* notification: hover status and margins
* start styling notifications, add separate files and basic functionalities
* fix tests
* start adding mystery items notification
* wip card notification
* fix cards text
* initial implementation inbox messages
* initial implementation group messages
* disable inbox notifications until mobile is ready
* wip group chat messages
* finish mystery and card notifications
* add bailey notification and fix a lot of stuff
* start adding guilds and parties invitations
* misc invitation fixes
* fix lint issues
* remove old code and add key to notifications
* fix tests
* remove unused code
* add link for public guilds invite
* starts to implement needs work notification design and feature
* fixes to needs work, add group task approved notification
* finish needs work feature
* lots of fixes
* implement quest notification
* bailey fixes and static page
* routing fixes
* fixes # this.$store.dispatch(guilds:join, {groupId: group.id, type: party});
* read notifications on click
* chat notifications
* fix tests for chat notifications
* fix chat notification test
* fix tests
* fix tests (again)
* try awaiting
* remove only
* more sleep
* add bailey tests
* fix icons alignment
* fix issue with multiple points notifications
* remove merge code
* fix rejecting guild invitation
* make remove area bigger
* fix error with notifications and add migration
* fix migration
* fix typos
* add cleanup migration too
* notifications empty state, new counter color, fix marking messages as seen in guilds
* fixes
* add image and install correct packages
* fix mongoose version
* update bailey
* typo
* make sure chat is marked as read after other requests
This commit is contained in:
@@ -106,6 +106,28 @@ schema.methods.sendMessage = async function sendMessage (userToReceiveMessage, o
|
||||
userToReceiveMessage._v++;
|
||||
userToReceiveMessage.markModified('inbox.messages');
|
||||
|
||||
/* @TODO disabled until mobile is ready
|
||||
|
||||
let excerpt;
|
||||
|
||||
if (!options.receiverMsg) {
|
||||
excerpt = '';
|
||||
} else if (options.receiverMsg.length < 100) {
|
||||
excerpt = options.receiverMsg;
|
||||
} else {
|
||||
excerpt = options.receiverMsg.substring(0, 100);
|
||||
}
|
||||
userToReceiveMessage.addNotification('NEW_INBOX_MESSAGE', {
|
||||
sender: {
|
||||
id: sender._id,
|
||||
name: sender.profile.name,
|
||||
},
|
||||
excerpt,
|
||||
messageId: newMessage.id,
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
common.refPush(sender.inbox.messages, defaults({sent: true}, chatDefaults(senderMsg, userToReceiveMessage)));
|
||||
sender.markModified('inbox.messages');
|
||||
|
||||
@@ -119,11 +141,13 @@ schema.methods.sendMessage = async function sendMessage (userToReceiveMessage, o
|
||||
*
|
||||
* @param type The type of notification to add to the this. Possible values are defined in the UserNotificaiton Schema
|
||||
* @param data The data to add to the notification
|
||||
* @param seen If the notification should be marked as seen
|
||||
*/
|
||||
schema.methods.addNotification = function addUserNotification (type, data = {}) {
|
||||
schema.methods.addNotification = function addUserNotification (type, data = {}, seen = false) {
|
||||
this.notifications.push({
|
||||
type,
|
||||
data,
|
||||
seen,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -137,13 +161,13 @@ schema.methods.addNotification = function addUserNotification (type, data = {})
|
||||
* @param type The type of notification to add to the this. Possible values are defined in the UserNotificaiton Schema
|
||||
* @param data The data to add to the notification
|
||||
*/
|
||||
schema.statics.pushNotification = async function pushNotification (query, type, data = {}) {
|
||||
let newNotification = new UserNotification({type, data});
|
||||
schema.statics.pushNotification = async function pushNotification (query, type, data = {}, seen = false) {
|
||||
let newNotification = new UserNotification({type, data, seen});
|
||||
let validationResult = newNotification.validateSync();
|
||||
if (validationResult) {
|
||||
throw validationResult;
|
||||
}
|
||||
await this.update(query, {$push: {notifications: newNotification}}, {multi: true}).exec();
|
||||
await this.update(query, {$push: {notifications: newNotification.toObject()}}, {multi: true}).exec();
|
||||
};
|
||||
|
||||
// Add stats.toNextLevel, stats.maxMP and stats.maxHealth
|
||||
|
||||
Reference in New Issue
Block a user