Message: Sender deletes own message_rel_user - refs BT#21988

pull/5817/head
Angel Fernando Quiroz Campos 2 months ago
parent bd739b314e
commit 85841b76e6
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 2
      assets/vue/views/message/MessageList.vue
  2. 2
      assets/vue/views/message/MessageShow.vue
  3. 11
      src/CoreBundle/Entity/Message.php
  4. 30
      src/CoreBundle/State/MessageProcessor.php

@ -429,7 +429,7 @@ function sortingChanged(event) {
}
function findMyReceiver(message) {
const receivers = [...message.receiversTo, ...message.receiversCc]
const receivers = [...message.receiversTo, ...message.receiversCc, ...message.receiversSender]
return receivers.find(({ receiver }) => receiver["@id"] === securityStore.user["@id"])
}

@ -188,7 +188,7 @@ store.dispatch("message/load", id).then((responseItem) => {
})
function findMyReceiver(message) {
const receivers = [...message.receiversTo, ...message.receiversCc]
const receivers = [...message.receiversTo, ...message.receiversCc, ...message.receiversSender]
return receivers.find(({ receiver }) => receiver["@id"] === securityStore.user["@id"])
}

@ -222,6 +222,17 @@ class Message
;
}
#[Groups(['message:read'])]
public function getReceiversSender(): array
{
return $this->receivers
->filter(
fn (MessageRelUser $messageRelUser) => MessageRelUser::TYPE_SENDER === $messageRelUser->getReceiverType()
)
->getValues()
;
}
#[Groups(['message:read'])]
public function getFirstReceiver(): ?MessageRelUser
{

@ -82,36 +82,6 @@ final class MessageProcessor implements ProcessorInterface
return $message;
}
private function processDeleteForUser($data): Message
{
/** @var Message $message */
$message = $data;
$request = $this->requestStack->getCurrentRequest();
if (!$request) {
throw new LogicException('Cannot get current request');
}
$requestData = json_decode($request->getContent(), true);
if (!isset($requestData['userId'])) {
throw new InvalidArgumentException('The field userId is required.');
}
$userId = $requestData['userId'];
$messageRelUserRepository = $this->entityManager->getRepository(MessageRelUser::class);
$messageRelUser = $messageRelUserRepository->findOneBy([
'message' => $message,
'receiver' => $userId,
]);
if ($messageRelUser) {
$this->entityManager->remove($messageRelUser);
$this->entityManager->flush();
}
return $message;
}
private function saveNotificationForInboxMessage(Message $message): void
{
$sender_info = api_get_user_info(

Loading…
Cancel
Save