1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-24 10:23:28 +00:00

Refactor Notifications structure

This commit is contained in:
2020-03-28 14:18:37 +01:00
parent bef85d2d91
commit 0882ac76b3
6 changed files with 131 additions and 143 deletions

View File

@ -4,8 +4,8 @@ import { LikesHelper, LikesType } from "../helpers/LikesHelper";
import { check_string_before_insert, removeHTMLNodes } from "../utils/StringUtils";
import { time } from "../utils/DateUtils";
import { CommentsHelper } from "../helpers/CommentsHelper";
import { NotificationsUtils } from "../utils/NotificationsUtils";
import { NotifEventType } from "../entities/Notification";
import { NotificationsHelper } from "../helpers/NotificationsHelper";
/**
* Comments controller
@ -46,7 +46,7 @@ export class CommentsController {
const commentID = await CommentsHelper.Create(newComment);
// Create notifications
await NotificationsUtils.CreatePostNotification(h.getUserId(), postID, NotifEventType.COMMENT_CREATED);
await NotificationsHelper.CreatePostNotification(h.getUserId(), postID, NotifEventType.COMMENT_CREATED);
// TODO : Delete any notifications targetting this user about the post

View File

@ -2,8 +2,8 @@ import { Friend } from "../entities/Friend";
import { RequestHandler } from "../entities/RequestHandler";
import { FriendsHelper } from "../helpers/FriendsHelper";
import { UserHelper } from "../helpers/UserHelper";
import { NotificationsUtils } from "../utils/NotificationsUtils";
import { NotifEventType } from "../entities/Notification";
import { NotificationsHelper } from "../helpers/NotificationsHelper";
/**
* Friends controller
@ -113,7 +113,7 @@ export class FriendsController {
await FriendsHelper.SendRequest(h.getUserId(), friendID);
// Create the notification
await NotificationsUtils.CreateFriendsNotifications(
await NotificationsHelper.CreateFriendsNotifications(
h.getUserId(), friendID, NotifEventType.SENT_FRIEND_REQUEST)
h.success("Send (create) the friendship request");
@ -133,7 +133,7 @@ export class FriendsController {
await FriendsHelper.RemoveRequest(h.getUserId(), friendID);
// Delete any related notification
await NotificationsUtils.DeleteNotificationsFrienshipRequest(h.getUserId(), friendID);
await NotificationsHelper.DeleteNotificationsFrienshipRequest(h.getUserId(), friendID);
h.success("Friendship request removed!");
}
@ -153,7 +153,7 @@ export class FriendsController {
await FriendsHelper.RespondRequest(h.getUserId(), friendID, accept);
// Create notification
await NotificationsUtils.CreateFriendsNotifications(h.getUserId(), friendID,
await NotificationsHelper.CreateFriendsNotifications(h.getUserId(), friendID,
accept ? NotifEventType.ACCEPTED_FRIEND_REQUEST : NotifEventType.REJECTED_FRIEND_REQUEST);
h.success("Response to the friendship request successfully saved!");
@ -170,7 +170,7 @@ export class FriendsController {
await FriendsHelper.RemoveFriendship(h.getUserId(), friendID);
// Delete any related notification
await NotificationsUtils.DeleteNotificationsFrienshipRequest(
await NotificationsHelper.DeleteNotificationsFrienshipRequest(
h.getUserId(), friendID);
h.success("The friend was removed from the list!");

View File

@ -8,8 +8,8 @@ import { GroupSettings } from "../entities/GroupSettings";
import { removeHTMLNodes, checkURL } from "../utils/StringUtils";
import { findKey } from "../utils/ArrayUtils";
import { checkVirtualDirectoryAvailability, VirtualDirType } from "../utils/VirtualDirsUtils";
import { NotificationsUtils } from "../utils/NotificationsUtils";
import { NotifEventType } from "../entities/Notification";
import { NotificationsHelper } from "../helpers/NotificationsHelper";
/**
* Groups API controller
@ -306,7 +306,7 @@ export class GroupsController {
await GroupsHelper.SendInvitation(groupID, userID);
// Create a notification
await NotificationsUtils.CreateGroupMembershipNotification(
await NotificationsHelper.CreateGroupMembershipNotification(
userID, h.getUserId(), groupID, NotifEventType.SENT_GROUP_MEMBERSHIP_INVITATION)
h.success("The user has been successfully invited to join the group!");
@ -329,7 +329,7 @@ export class GroupsController {
await GroupsHelper.RespondInvitation(groupID, h.getUserId(), accept);
// Create a notification
await NotificationsUtils.CreateGroupMembershipNotification(
await NotificationsHelper.CreateGroupMembershipNotification(
h.getUserId(), 0, groupID,
accept ? NotifEventType.ACCEPTED_GROUP_MEMBERSHIP_INVITATION : NotifEventType.REJECTED_GROUP_MEMBERSHIP_INVITATION
)

View File

@ -19,8 +19,8 @@ import { statSync } from "fs";
import { lookup } from "mime-types";
import { NewSurvey } from "../entities/NewSurvey";
import { FriendsHelper } from "../helpers/FriendsHelper";
import { NotificationsUtils } from "../utils/NotificationsUtils";
import { NotifEventType } from "../entities/Notification";
import { NotificationsHelper } from "../helpers/NotificationsHelper";
/**
* Posts controller
@ -294,7 +294,7 @@ export class PostsController {
// Create a notification
await NotificationsUtils.CreatePostNotification(
await NotificationsHelper.CreatePostNotification(
h.getUserId(), postID, NotifEventType.ELEM_CREATED);
h.send({