notification: group attendees and reactions

This commit is contained in:
Yurii
2026-04-06 17:31:22 +03:00
parent de544415f1
commit c100adc3e5
5 changed files with 27 additions and 12 deletions

View File

@@ -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';

View File

@@ -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(),

View File

@@ -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,

View File

@@ -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',
];
}
}

View File

@@ -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';