Skip to content

EspoCRM – Open Source CRM Application

notification: group attendees and reactions

Yuriic100adc3e56b
diff --git a/application/Espo/Entities/Notification.php b/application/Espo/Entities/Notification.php
index 68ea7ea6a0..01e6fba74f 100644
--- a/application/Espo/Entities/Notification.php
+++ b/application/Espo/Entities/Notification.php
@@ -65,7 +65,7 @@ class Notification extends Entity
public const string FIELD_RELATED_PARENT = 'relatedParent';
public const string FIELD_IS_FEATURED = 'isFeatured';
- public const string GROUP_TYPE_NOTE = Notification::TYPE_NOTE;
+ public const string GROUP_TYPE_RECORD = 'Record';
public const string GROUP_TYPE_EMAIL_RECEIVED = Notification::TYPE_EMAIL_RECEIVED;
public const string DATE_ATTR_NOTE_ID = 'noteId';
diff --git a/application/Espo/Modules/Crm/Classes/AssignmentNotificators/Meeting.php b/application/Espo/Modules/Crm/Classes/AssignmentNotificators/Meeting.php
index 143a3a3ba2..1a9ed6a15a 100644
--- a/application/Espo/Modules/Crm/Classes/AssignmentNotificators/Meeting.php
+++ b/application/Espo/Modules/Crm/Classes/AssignmentNotificators/Meeting.php
@@ -115,6 +115,8 @@ class Meeting implements AssignmentNotificator
->setType(self::NOTIFICATION_TYPE_EVENT_ATTENDEE)
->setUserId($userId)
->setRelated(LinkParent::fromEntity($entity))
+ // Needed for notification grouping.
+ ->setRelatedParent(LinkParent::fromEntity($entity))
->setData([
'entityType' => $entity->getEntityType(),
'entityId' => $entity->getId(),
diff --git a/application/Espo/Tools/Notification/GroupAllService.php b/application/Espo/Tools/Notification/GroupAllService.php
index 9ff5892cd8..bd94469275 100644
--- a/application/Espo/Tools/Notification/GroupAllService.php
+++ b/application/Espo/Tools/Notification/GroupAllService.php
@@ -84,7 +84,7 @@ class GroupAllService
{
$collection = null;
- if ($type == Notification::GROUP_TYPE_NOTE) {
+ if ($type == Notification::GROUP_TYPE_RECORD) {
$collection = $this->getNote($groupId, $searchParams);
} else if ($type == Notification::GROUP_TYPE_EMAIL_RECEIVED) {
$collection = $this->getEmailReceived($searchParams);
@@ -121,7 +121,7 @@ class GroupAllService
$query = $builder
->where([
- Notification::FIELD_TYPE => Notification::TYPE_NOTE,
+ Notification::FIELD_TYPE => $this->recordService->getRecordGroupNoteTypes(),
Notification::ATTR_RELATED_PARENT_TYPE => $entityType,
Notification::ATTR_RELATED_PARENT_ID => $id,
])
@@ -181,7 +181,7 @@ class GroupAllService
[$type,] = explode('_', $groupId, 2);
- if ($type == Notification::GROUP_TYPE_NOTE) {
+ if ($type == Notification::GROUP_TYPE_RECORD) {
$this->markReadNote($groupId);
return;
@@ -262,7 +262,7 @@ class GroupAllService
[$type,] = explode('_', $groupId, 2);
- if ($type == Notification::GROUP_TYPE_NOTE) {
+ if ($type == Notification::GROUP_TYPE_RECORD) {
$this->removeNote($groupId);
return;
@@ -294,7 +294,7 @@ class GroupAllService
Notification::ATTR_USER_ID => $this->user->getId(),
])
->where([
- Notification::FIELD_TYPE => Notification::TYPE_NOTE,
+ Notification::FIELD_TYPE => $this->recordService->getRecordGroupNoteTypes(),
Notification::ATTR_RELATED_PARENT_TYPE => $entityType,
Notification::ATTR_RELATED_PARENT_ID => $id,
])
@@ -335,7 +335,7 @@ class GroupAllService
Notification::ATTR_USER_ID => $this->user->getId(),
])
->where([
- Notification::FIELD_TYPE => Notification::TYPE_NOTE,
+ Notification::FIELD_TYPE => $this->recordService->getRecordGroupNoteTypes(),
Notification::ATTR_RELATED_PARENT_TYPE => $entityType,
Notification::ATTR_RELATED_PARENT_ID => $id,
Notification::ATTR_READ => false,
diff --git a/application/Espo/Tools/Notification/RecordService.php b/application/Espo/Tools/Notification/RecordService.php
index 94e5912a00..7ad0e11c79 100644
--- a/application/Espo/Tools/Notification/RecordService.php
+++ b/application/Espo/Tools/Notification/RecordService.php
@@ -658,12 +658,12 @@ class RecordService
->buildQueryBuilder()
->select([
Selection::create(
- Expr::value(Notification::GROUP_TYPE_NOTE),
+ Expr::value(Notification::GROUP_TYPE_RECORD),
self::COLUMN_GROUP_TYPE
),
Selection::create(
Expr::concat(
- Expr::value(Notification::GROUP_TYPE_NOTE),
+ Expr::value(Notification::GROUP_TYPE_RECORD),
Expr::value('_'),
Expr::column(Notification::ATTR_RELATED_PARENT_TYPE),
Expr::value('_'),
@@ -719,7 +719,7 @@ class RecordService
])
->where([
Notification::ATTR_RELATED_PARENT_ID . '!=' => null,
- Notification::FIELD_TYPE => Notification::TYPE_NOTE,
+ Notification::FIELD_TYPE => $this->getRecordGroupNoteTypes(),
])
->where([Notification::ATTR_USER_ID => $user->getId()])
->group(Notification::ATTR_RELATED_PARENT_ID)
@@ -889,7 +889,7 @@ class RecordService
->where([
[
'OR' => [
- Notification::FIELD_TYPE . '!=' => Notification::TYPE_NOTE,
+ Notification::FIELD_TYPE . '!=' => $this->getRecordGroupNoteTypes(),
Notification::ATTR_RELATED_PARENT_ID => null,
],
],
@@ -914,4 +914,17 @@ class RecordService
{
return Expr::max(Expr::column(Notification::ATTR_NUMBER));
}
+
+ /**
+ * @internal
+ * @return string[]
+ */
+ public function getRecordGroupNoteTypes(): array
+ {
+ return [
+ Notification::TYPE_NOTE,
+ Notification::TYPE_USER_REACTION,
+ 'EventAttendee',
+ ];
+ }
}
diff --git a/client/src/views/notification/fields/container.js b/client/src/views/notification/fields/container.js
index 5fca5d9232..a58516426e 100644
--- a/client/src/views/notification/fields/container.js
+++ b/client/src/views/notification/fields/container.js
@@ -136,7 +136,7 @@ class NotificationContainerFieldView extends BaseFieldView {
let viewName;
- if (groupType === 'Note') {
+ if (groupType === 'Record') {
viewName = 'views/notification/items/group-note';
} else if (groupType === 'EmailReceived') {
viewName = 'views/notification/items/group-email-received';