39 if (!$saveResult->isSuccess())
41 return $result->addErrors($saveResult->getErrors());
46 $pushRecipient = [
'RECIPIENT' => [$this->getContext()->getUserId()]];
49 ->setContext($this->context)
50 ->sendFull($favoriteMessage, static::ADD_FAVORITE_MESSAGE_EVENT, $pushRecipient)
62 if ($favoriteMessage ===
null)
67 $deleteResult = $favoriteMessage->delete();
69 if (!$deleteResult->isSuccess())
71 return $result->addErrors($deleteResult->getErrors());
76 if (!$deleteParamResult->isSuccess())
78 return $result->addErrors($deleteParamResult->getErrors());
81 $pushRecipient = [
'RECIPIENT' => [$this->getContext()->getUserId()]];
84 ->setContext($this->context)
85 ->sendIdOnly($favoriteMessage, static::DELETE_FAVORITE_MESSAGE_EVENT, $pushRecipient)
136 $favoriteListParam = $message->
getParams()->get(Params::FAVORITE)->getValue() ?: [];
137 $userId = $this->getContext()->getUserId();
138 if (!in_array($userId, $favoriteListParam,
true))
140 $message->
getParams()->get(Params::FAVORITE)->addValue($userId);
142 \CIMMessageParam::SendPull($message->
getMessageId(), [Params::FAVORITE]);
150 $favoriteListParam = $message->
getParams()->get(Params::FAVORITE)->getValue() ?: [];
151 $userId = $this->getContext()->getUserId();
152 if (in_array($userId, $favoriteListParam,
true))
154 $message->
getParams()->get(Params::FAVORITE)->unsetValue($userId);
156 \CIMMessageParam::SendPull($message->
getMessageId(), [Params::FAVORITE]);