Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Message.php
1<?php
2
3namespace Bitrix\Im\V2;
4
5use ArrayAccess;
13use Bitrix\Im;
18use Bitrix\Im\Model\EO_Message;
20use Bitrix\Im\V2\Common\ContextCustomer;
21use Bitrix\Im\V2\Common\FieldAccessImplementation;
22use Bitrix\Im\V2\Common\ActiveRecordImplementation;
23use Bitrix\Im\V2\Common\RegistryEntryImplementation;
39
44{
45 use FieldAccessImplementation;
46 use ActiveRecordImplementation
47 {
48 save as defaultSave;
49 }
50 use RegistryEntryImplementation;
51 use ContextCustomer;
52
53 public const MESSAGE_MAX_LENGTH = 20000;
54 public const REST_FIELDS = ['ID', 'CHAT_ID', 'AUTHOR_ID', 'DATE_CREATE', 'MESSAGE', 'NOTIFY_EVENT'];
55
56 protected ?int $messageId = null;
57
58 protected ?int $chatId = null;
59
60 protected ?Chat $chat = null;
61
63 protected int $authorId = 0;
64 protected array $userIdsFromMention;
65
67 protected ?string $message = null;
68
69 protected ?string $parsedMessage = null;
70
71 protected ?string $formattedMessage = null;
72
74 protected ?string $messageOut = null;
75
77 protected ?DateTime $dateCreate = null;
78
80 protected ?string $emailTemplate = null;
81
89 protected int $notifyType = \IM_NOTIFY_MESSAGE;
90
92 protected ?string $notifyModule = null;
93
95 protected ?string $notifyEvent = null;
96
98 protected ?string $notifyTag = null;
99
101 protected ?string $notifySubTag = null;
102
104 protected ?string $notifyTitle = null;
105
107 protected ?string $notifyLink = null;
108
115 protected ?array $notifyButtons = null;
116
118 protected ?bool $notifyRead = null;
119
121 protected ?bool $notifyAnswer = null;
122
124 protected ?bool $notifyFlash = null;
125
127 protected ?int $importId = null;
128
129 protected ?bool $isUnread = null;
130
131 protected ?bool $isViewed = null;
132
133 protected ?bool $isViewedByOthers = null;
134
136 protected Params $params;
137
142 protected ?FileCollection $files = null;
143
145
147 protected bool $isSystem = false;
148
149 protected ?UrlItem $url;
150
151 protected int $botId = 0;
152
154 protected ?string $uuid = null;
155
156 protected ?string $forwardUuid = null;
157
159 protected ?string $fileUuid = null;
160
161 protected bool $isUuidFilled = false;
162 protected bool $isUrlFilled = false;
163
164 protected ?string $pushMessage = null;
165 protected ?array $pushParams = null;
166 protected ?string $pushAppId = null;
167
168 protected ?bool $isImportant = false;
169
170 protected ?array $importantFor = null;
171
175 public function __construct($source = null)
176 {
177 $this->params = new Params;
178
179 $this->initByDefault();
180
181 if (!empty($source))
182 {
183 $this->load($source);
184 }
185 }
186
187 public function save(): Result
188 {
189 $checkParamsIsValid = $this->getParams()->isValid();
190
191 if (!$checkParamsIsValid->isSuccess())
192 {
193 return $checkParamsIsValid;
194 }
195
196 $result = $this->defaultSave();
197
198 if ($result->isSuccess())
199 {
200 $this->params->setMessageId($this->getMessageId());
201
202 $paramsSaveResult = $this->params->save();
203 if (!$paramsSaveResult->isSuccess())
204 {
205 $result->addErrors($paramsSaveResult->getErrors());
206 }
207 }
208
209 return $result;
210 }
211
212 //region Setters & Getters
213
214 public function getId(): ?int
215 {
216 return $this->getMessageId();
217 }
218
219 public function markAsSystem(bool $flag): self
220 {
221 $this->isSystem = $flag;
222
223 return $this;
224 }
225
226 public function isSystem(): bool
227 {
228 return $this->isSystem;
229 }
230
231 public function isDisappearing(): bool
232 {
233 return (bool)$this->getDisappearingTime();
234 }
235
236 public function getDisappearingTime(): ?DateTime
237 {
238 if ($this->getMessageId())
239 {
240 $row = Im\Model\MessageDisappearingTable::getRowById($this->getMessageId());
241
242 return $row['DATE_REMOVE'];
243 }
244
245 return null;
246 }
247
248 public function isImportant(): ?bool
249 {
250 return $this->isImportant;
251 }
252
253 public function markAsImportant(?bool $isImportant = true): self
254 {
255 $this->isImportant = $isImportant;
256
257 return $this;
258 }
259
260 public function getImportantFor(): array
261 {
262 return $this->importantFor ?? array_values($this->getUserIdsFromMention());
263 }
264
265 public function setImportantFor(array $importantFor): self
266 {
267 $this->importantFor = $importantFor;
268
269 return $this;
270 }
271
272 public function getForwardUuid(): ?string
273 {
274 return $this->forwardUuid;
275 }
276
277 public function setForwardUuid(?string $forwardUuid): self
278 {
279 if ($forwardUuid && Im\Message\Uuid::validate($forwardUuid))
280 {
281 $this->forwardUuid = $forwardUuid;
282 }
283
284 return $this;
285 }
286
291 public function setParams($params): self
292 {
293 $this->getParams()->load($params);
294
295 return $this;
296 }
297
302 public function resetParams($params): self
303 {
304 $this->getParams()->delete();
305
306 return $this->setParams($params);
307 }
308
313 public function getParams(bool $disallowLazyLoad = false): Params
314 {
315 if (
316 $disallowLazyLoad != true
317 && !$this->params->isLoaded()
318 && $this->getMessageId()
319 )
320 {
321 // lazyload
322 $this->params->loadByMessageId($this->getMessageId());
323 }
324
325 return $this->params;
326 }
327
332 public function setAttach($attach): self
333 {
334 $this->getParams()->get(Params::ATTACH)->setValue($attach);
335 return $this;
336 }
337
341 public function getAttach(): AttachArray
342 {
343 return $this->getParams()->get(Params::ATTACH);
344 }
345
346 public function setUrl(?UrlItem $url): self
347 {
348 $this->url = $url;
349 $this->isUrlFilled = true;
350
351 return $this;
352 }
353
354 public function getUrl(): ?UrlItem
355 {
356 if (isset($this->url))
357 {
358 return $this->url;
359 }
360
361 $urlId = $this->getParams()->get(Params::URL_ID)->getValue()[0] ?? null;
362 if (isset($urlId) && !$this->isUrlFilled)
363 {
364 return UrlItem::initByPreviewUrlId($urlId, false);
365 }
366
367 return null;
368 }
369
370 public function setUnread(bool $isUnread): self
371 {
372 $this->isUnread = $isUnread;
373
374 return $this;
375 }
376
377 public function isUnread(): bool
378 {
379 if (isset($this->isUnread))
380 {
381 return $this->isUnread;
382 }
383
384 $messageIds = [$this->getMessageId()];
385 $this->isUnread = !(new ReadService())->getReadStatusesByMessageIds($messageIds)[$this->getMessageId()];
386
387 return $this->isUnread;
388 }
389
390 public function setViewed(bool $isViewed): self
391 {
392 $this->isViewed = $isViewed;
393
394 return $this;
395 }
396
397 public function isViewed(): bool
398 {
399 if (isset($this->isViewed))
400 {
401 return $this->isViewed;
402 }
403
404 if ($this->authorId === $this->getContext()->getUserId())
405 {
406 $this->isViewed = true;
407
408 return $this->isViewed;
409 }
410
411 $messageIds = [$this->getMessageId()];
412 $this->isViewed = (new ReadService())->getViewStatusesByMessageIds($messageIds)[$this->getMessageId()];
413
414 return $this->isViewed;
415 }
416
417 public function setViewedByOthers(bool $isViewedByOthers): self
418 {
419 $this->isViewedByOthers = $isViewedByOthers;
420
421 return $this;
422 }
423
424 public function isViewedByOthers(): bool
425 {
426 if (isset($this->isViewedByOthers))
427 {
428 return $this->isViewedByOthers;
429 }
430
431 $this->isViewedByOthers = (new ViewedService())->getMessageStatus($this->getMessageId()) === \IM_MESSAGE_STATUS_DELIVERED;
432
433 return $this->isViewedByOthers;
434 }
435
436 public function setBotId(int $botId): self
437 {
438 $this->botId = $botId;
439
440 return $this;
441 }
442
447 public function setKeyboard($keyboard): self
448 {
449 if (is_array($keyboard))
450 {
451 $value = [];
452 if (!isset($keyboard['BUTTONS']))
453 {
454 $value['BUTTONS'] = $keyboard;
455 }
456 else
457 {
458 $value = $keyboard;
459 }
460 if (!isset($value['BOT_ID']))
461 {
462 $value['BOT_ID'] = $this->botId;
463 }
464 $keyboard = $value;
465 }
466
467 $this->getParams()->get(Params::KEYBOARD)->setValue($keyboard);
468 return $this;
469 }
470
474 public function getKeyboard(): Keyboard
475 {
476 return $this->getParams()->get(Params::KEYBOARD);
477 }
478
479 /*
480 * @param array|Parameter|Menu $menu
481 */
482 public function setMenu($menu): self
483 {
484 if (is_array($menu))
485 {
486 $value = [];
487 if (!isset($menu['ITEMS']))
488 {
489 $value['ITEMS'] = $menu;
490 }
491 else
492 {
493 $value = $menu;
494 }
495 if (!isset($value['BOT_ID']))
496 {
497 $value['BOT_ID'] = $this->botId;
498 }
499 $menu = $value;
500 }
501
502 $this->getParams()->get(Params::MENU)->setValue($menu);
503 return $this;
504 }
505
509 public function getMenu(): Menu
510 {
511 return $this->getParams()->get(Params::MENU);
512 }
513
514 //region UUID
515
520 public function setUuid(?string $uuid): self
521 {
522 $this->isUuidFilled = true;
523
524 if ($uuid && Im\Message\Uuid::validate($uuid))
525 {
526 $this->uuid = $uuid;
527 }
528
529 return $this;
530 }
531
532 public function getUuid(): ?string
533 {
534 if ($this->isUuidFilled)
535 {
536 return $this->uuid;
537 }
538
539 $this->isUuidFilled = true;
540 $this->uuid = null;
541
542 if ($this->getMessageId())
543 {
544 $row = Im\Model\MessageUuidTable::query()
545 ->setSelect(['UUID'])
546 ->where('MESSAGE_ID', $this->getMessageId())
547 ->fetch() ?: [];
548
549 $this->uuid = $row['UUID'] ?? null;
550 }
551
552 return $this->uuid;
553 }
554
555 public function setFileUuid(?string $uuid): self
556 {
557 $this->fileUuid = $uuid;
558 return $this;
559 }
560
561 public function getFileUuid(): ?string
562 {
563 return $this->fileUuid;
564 }
565
566 //endregion
567
568 //region Files
569
573 public function getFileIds(): array
574 {
575 if ($this->getParams()->isSet(Params::FILE_ID))
576 {
577 return $this->getParams()->get(Params::FILE_ID)->getValue();
578 }
579
580 return [];
581 }
582
586 public function hasFiles(): bool
587 {
588 return
589 $this->getParams()->isSet(Params::FILE_ID)
590 && ($this->getParams()->get(Params::FILE_ID)->count() > 0);
591 }
592
597 public function setFiles($files): self
598 {
599 $fileIds = [];
600 if ($files instanceof FileCollection)
601 {
602 $this->files = $files;
603 foreach ($this->files as $fileItem)
604 {
605 $fileIds[] = $fileItem->getDiskFileId();
606 }
607 }
608 elseif (is_array($files))
609 {
610 $fileIds = array_filter(array_map('intval', array_values($files)));
611 }
612
613 $this->getParams()->get(Params::FILE_ID)->setValue($fileIds);
614
615 return $this;
616 }
617
618 public function fillFiles(FileCollection $files): self
619 {
620 $this->files = $files;
621
622 return $this;
623 }
624
625 public function addFile(Im\V2\Entity\File\FileItem $file): self
626 {
627 $this->getFiles()[] = $file;
628 $this->getParams()->get(Params::FILE_ID)->addValue($file->getId());
629
630 return $this;
631 }
632
636 public function getFiles(): FileCollection
637 {
638 if (!$this->files instanceof FileCollection)
639 {
640 $fileIds = $this->getFileIds();
641 if (!empty($fileIds))
642 {
643 $this->files = FileCollection::initByDiskFilesIds($fileIds, $this->getChatId());
644 }
645 else
646 {
647 $this->files = new FileCollection;
648 }
649 }
650
651 return $this->files;
652 }
653
658 public function setReactions(Im\V2\Message\Reaction\ReactionMessage $reactions): self
659 {
660 $this->reactions = $reactions;
661
662 return $this;
663 }
664
669 {
670 $this->reactions ??= Im\V2\Message\Reaction\ReactionMessage::getByMessageId($this->getMessageId());
671
672 return $this->reactions;
673 }
674
680 public function uploadFileFromText(): array
681 {
682 $files = [];
683 if ($this->getMessage() && $this->getChatId())
684 {
685 $message = $this->getMessage();
686 if (preg_match_all("/\[DISK=([0-9]+)\]/i", $message, $matches))
687 {
688 $fileFound = false;
689 foreach ($matches[1] as $fileId)
690 {
691 $newFile = \CIMDisk::SaveFromLocalDisk($this->getChatId(), $fileId, false, $this->getContext()->getUserId());
692 if ($newFile)
693 {
694 $files[] = $newFile;
695 $fileFound = true;
696 $file = new Im\V2\Entity\File\FileItem($newFile, $this->getChatId());
697 $this->addFile($file);
698 }
699 }
700 if ($fileFound)
701 {
702 $message = preg_replace("/\[DISK\=([0-9]+)\]/i", '', $message);
703 }
704 $this->setMessage($message);
705 }
706 }
707
708 return $files;
709 }
710
711 public function formatFilesMessageOut(): self
712 {
713 if ($this->getChatId() && $this->hasFiles())
714 {
715 $messageFiles = $this->formatFileLinks();
716 if (!empty($messageFiles))
717 {
718 $messageOut = $this->getMessageOut() ? $this->getMessageOut() . "\n" : '';
719 $messageOut .= implode("\n", $messageFiles);
720 $this->setMessageOut($messageOut);
721 }
722 }
723
724 return $this;
725 }
726
730 public function getFilesDiskData(): array
731 {
732 if ($this->hasFiles())
733 {
734 return $this->getFiles()->getFileDiskAttributes($this->getChatId());
735 }
736
737 return [];
738 }
739
740 private function formatFileLinks(): array
741 {
742 $messageFiles = [];
743
744 $filesDataList = $this->getFilesDiskData();
745 if (!empty($filesDataList))
746 {
747 $urlManager = UrlManager::getInstance();
748 $hostUrl = $urlManager->getHostUrl();
749 foreach ($filesDataList as $fileData)
750 {
751 if ($fileData['status'] == 'done')
752 {
753 $messageFiles[] =
754 $fileData['name'] . ' (' . \CFile::formatSize($fileData['size']) . ')'
755 . "\n" . Loc::getMessage('IM_MESSAGE_FILE_DOWN')
756 . ' ' . $hostUrl . $fileData['urlDownload']
757 . "\n";
758 }
759 }
760 }
761
762 return $messageFiles;
763 }
764
765 //endregion
766
767 public function getReminder(): ?Link\Reminder\ReminderItem
768 {
769 return Link\Reminder\ReminderItem::getByMessageAndUserId($this, $this->getContext()->getUserId());
770 }
771
772 public function getAdditionalMessageIds(): array
773 {
774 $ids = [];
775
776 if ($this->getParams()->isSet(Params::REPLY_ID))
777 {
778 $ids[] = $this->getParams()->get(Params::REPLY_ID)->getValue();
779 }
780
781 return $ids;
782 }
783
784 public function getPopupData(array $excludedList = []): PopupData
785 {
786 $data = new PopupData([
787 new Im\V2\Entity\User\UserPopupItem($this->getUserIds()),
788 new Im\V2\Entity\File\FilePopupItem(),
789 new Im\V2\Link\Reminder\ReminderPopupItem(),
791 ], $excludedList);
792
793 if (!in_array(Im\V2\Entity\File\FilePopupItem::class, $excludedList, true))
794 {
795 $data->add(new Im\V2\Entity\File\FilePopupItem($this->getFiles()));
796 }
797
798 if (!in_array(Im\V2\Link\Reminder\ReminderPopupItem::class, $excludedList, true))
799 {
800 $data->add(new Im\V2\Link\Reminder\ReminderPopupItem($this->getReminder()));
801 }
802
803 return $data->mergeFromEntity($this->getReactions());
804 }
805
806 public function setMessageId(int $messageId): self
807 {
808 if (!$this->messageId)
809 {
810 $this->messageId = $messageId;
811 $this->params->setMessageId($messageId);
812 }
813 return $this;
814 }
815
816 public function getMessageId(): ?int
817 {
818 return $this->messageId;
819 }
820
821 public function setAuthorId(int $authorId): self
822 {
823 $this->authorId = $authorId;
824
825 $this->processChangeAuthorId($authorId);
826
827 return $this;
828 }
829
830 public function processChangeAuthorId(int $authorId): int
831 {
832 if ($authorId === 0)
833 {
834 $this->markAsSystem(true);
835 }
836
837 return $authorId;
838 }
839
840 public function getAuthorId(): int
841 {
842 return $this->authorId;
843 }
844
845 public function getAuthor(): ?User
846 {
847 if ($this->getAuthorId())
848 {
849 return User::getInstance($this->getAuthorId());
850 }
851
852 return null;
853 }
854
855 public function setChatId(int $value): self
856 {
857 $this->chatId = $value;
858 return $this;
859 }
860
861 public function setChat(Chat $chat): self
862 {
863 $this->chat = $chat;
864 return $this;
865 }
866
867 public function getChatId(): ?int
868 {
869 return $this->chatId;
870 }
871
872 public function getChat(): Chat
873 {
874 if (!$this->chat)
875 {
876 if ($this->getChatId())
877 {
878 $this->chat = Chat::getInstance($this->getChatId());
879 }
880 if ($this->chat)
881 {
882 $this->setRegistry($this->chat->getMessageRegistry());
883 }
884 else
885 {
886 return new Im\V2\Chat\NullChat();
887 }
888 }
889
890 return $this->chat;
891 }
892
893 // message
894 public function setMessage(?string $value): self
895 {
896 if ($value)
897 {
898 $value = \trim(\str_replace(['[BR]', '[br]', '#BR#'], "\n", $value));
899
900 if (\mb_strlen($value) > self::MESSAGE_MAX_LENGTH + 6)
901 {
902 $value = \mb_substr($value, 0, self::MESSAGE_MAX_LENGTH). ' (...)';
903 }
904 }
905
906 $this->message = $value ?: '';
907 unset($this->parsedMessage, $this->formattedMessage, $this->url);
908 return $this;
909 }
910
911 public function getMessage(): ?string
912 {
913 return $this->message;
914 }
915
916 public function getParsedMessage(): string
917 {
918 $this->parsedMessage ??= Im\Text::parse($this->getMessage() ?? '');
919
920 return $this->parsedMessage;
921 }
922
923 public function getFormattedMessage(): string
924 {
925 if (isset($this->formattedMessage))
926 {
927 return $this->formattedMessage;
928 }
929
930 $this->formattedMessage =
931 $this->isCompletelyEmpty()
932 ? Loc::getMessage('IM_MESSAGE_DELETED')
933 : $this->getParsedMessage()
934 ;
935
936 return $this->formattedMessage;
937 }
938
939 public function getQuotedMessage(?int $messageSize = null): string
940 {
941 $user = $this->getAuthor();
942 $userName = isset($user) ? $user->getFullName(false) : '';
943 $date = FormatDate('X', $this->getDateCreate(), time() + \CTimeZone::GetOffset());
944 $contextTag = $this->getContextTag();
945 $quoteDelimiter = '------------------------------------------------------';
946 $messageContent = $this->getPreviewMessage($messageSize);
947
948 $quotedMessage =
949 $quoteDelimiter
950 . "\n"
951 . "{$userName} [{$date}] $contextTag\n"
952 . $messageContent
953 . "\n"
954 . $quoteDelimiter
955 ;
956
957 return $quotedMessage;
958 }
959
960 public function getReplaceMap(): array
961 {
962 return Im\Text::getReplaceMap($this->getFormattedMessage());
963 }
964
965 // formatted rich message to output
966 public function setMessageOut(?string $value): self
967 {
968 $this->messageOut = $value ? trim($value) : '';
969 return $this;
970 }
971
972 public function getMessageOut(): ?string
973 {
974 return $this->messageOut;
975 }
976
977 // date create
978
983 public function setDateCreate($value): self
984 {
985 if (!empty($value) && !($value instanceof DateTime))
986 {
987 try
988 {
989 $value = new DateTime($value);
990 }
991 catch (ObjectException $exception)
992 {}
993 }
994 $this->dateCreate = $value ?: null;
995 return $this;
996 }
997
998 public function getDateCreate(): ?DateTime
999 {
1000 return $this->dateCreate;
1001 }
1002
1004 {
1005 return new DateTime;
1006 }
1007
1008 public function setEmailTemplate(?string $value): self
1009 {
1010 $this->emailTemplate = $value ?: '';
1011 return $this;
1012 }
1013
1014 public function getEmailTemplate(): ?string
1015 {
1016 return $this->emailTemplate;
1017 }
1018
1019 public function setNotifyType(?int $value): self
1020 {
1021 if (in_array($value, [\IM_NOTIFY_MESSAGE, \IM_NOTIFY_CONFIRM, \IM_NOTIFY_SYSTEM, \IM_NOTIFY_FROM], true))
1022 {
1023 $this->notifyType = $value;
1024 }
1025 return $this;
1026 }
1027
1028 public function getNotifyType(): int
1029 {
1030 return $this->notifyType;
1031 }
1032
1033 public function getDefaultNotifyType(): int
1034 {
1035 return \IM_NOTIFY_MESSAGE;
1036 }
1037
1038 public function setNotifyModule(?string $value): self
1039 {
1040 $this->notifyModule = $value;
1041 return $this;
1042 }
1043
1044 public function getNotifyModule(): ?string
1045 {
1046 return $this->notifyModule;
1047 }
1048
1049 public function getDefaultNotifyModule(): ?string
1050 {
1051 return 'im';
1052 }
1053
1059 public function setNotifyEvent(?string $notifyEvent): self
1060 {
1061 $this->notifyEvent = $notifyEvent;
1062
1063 $this->processChangeNotifyEvent($notifyEvent);
1064
1065 return $this;
1066 }
1067
1068 public function processChangeNotifyEvent(?string $notifyEvent): ?string
1069 {
1070 if ($notifyEvent === Notify::EVENT_PRIVATE_SYSTEM)
1071 {
1072 $this->markAsSystem(true);
1073 }
1074
1075 return $notifyEvent;
1076 }
1077
1083 public function getNotifyEvent(): ?string
1084 {
1085 return $this->notifyEvent;
1086 }
1087
1088 public function getDefaultNotifyEvent(): ?string
1089 {
1090 return Notify::EVENT_DEFAULT;
1091 }
1092
1093 public function setNotifyTag(?string $value): self
1094 {
1095 $this->notifyTag = $value;
1096 return $this;
1097 }
1098
1099 public function getNotifyTag(): ?string
1100 {
1101 return $this->notifyTag;
1102 }
1103
1104 public function setNotifySubTag(?string $value): self
1105 {
1106 $this->notifySubTag = $value;
1107 return $this;
1108 }
1109
1110 public function getNotifySubTag(): ?string
1111 {
1112 return $this->notifySubTag;
1113 }
1114
1115 public function setNotifyTitle(?string $value): self
1116 {
1117 $this->notifyTitle = $value ? mb_substr(trim($value), 0, 255) : null;
1118 return $this;
1119 }
1120
1121 public function getNotifyTitle(): ?string
1122 {
1123 return $this->notifyTitle;
1124 }
1125
1126 public function setNotifyLink(?string $value): self
1127 {
1128 $this->notifyLink = $value;
1129 return $this;
1130 }
1131
1132 public function getNotifyLink(): ?string
1133 {
1134 return $this->notifyLink;
1135 }
1136
1137 public function setNotifyButtons($value): self
1138 {
1139 if (is_string($value))
1140 {
1141 $value = $this->unserializeNotifyButtons($value);
1142 }
1143 $this->notifyButtons = $value;
1144 return $this;
1145 }
1146
1147 public function getNotifyButtons(): ?array
1148 {
1149 return $this->notifyButtons;
1150 }
1151
1152 protected function serializeNotifyButtons($value)
1153 {
1154 return $value ? serialize($value) : null;
1155 }
1156
1157 protected function unserializeNotifyButtons($value)
1158 {
1159 return $value ? unserialize($value, ['allowed_classes' => false]) : null;
1160 }
1161
1162 public function markNotifyRead(?bool $value): self
1163 {
1164 $this->notifyRead = $value ?: false;
1165 return $this;
1166 }
1167
1168 public function isNotifyRead(): ?bool
1169 {
1170 return $this->notifyRead;
1171 }
1172
1173 public function getDefaultNotifyRead(): bool
1174 {
1175 return false;
1176 }
1177
1178 public function markNotifyAnswer(?bool $value): self
1179 {
1180 $this->notifyAnswer = $value ?: false;
1181 return $this;
1182 }
1183
1184 public function allowNotifyAnswer(): ?bool
1185 {
1186 return $this->notifyAnswer;
1187 }
1188
1189 public function markNotifyFlash(?bool $value): self
1190 {
1191 $this->notifyFlash = $value;
1192 return $this;
1193 }
1194
1195 public function isNotifyFlash(): ?bool
1196 {
1197 return $this->notifyFlash;
1198 }
1199
1200 public function setImportId(?int $value): self
1201 {
1202 $this->importId = $value;
1203 return $this;
1204 }
1205
1206 public function getImportId(): ?int
1207 {
1208 return $this->importId;
1209 }
1210
1211 //endregion
1212
1213 //region Push
1214
1220 public function setPushMessage(?string $message): self
1221 {
1222 $this->pushMessage = $message;
1223 return $this;
1224 }
1225
1226 public function getPushMessage(): ?string
1227 {
1228 return $this->pushMessage;
1229 }
1230
1236 public function setPushParams(?array $params): self
1237 {
1238 $this->pushParams = $params;
1239 return $this;
1240 }
1241
1242 public function getPushParams(): ?array
1243 {
1244 return $this->pushParams;
1245 }
1246
1252 public function setPushAppId(?string $message): self
1253 {
1254 $this->pushAppId = $message;
1255 return $this;
1256 }
1257
1258 public function getPushAppId(): ?string
1259 {
1260 return $this->pushAppId;
1261 }
1262
1263
1264 //endregion
1265
1266 //region Data storage
1267
1271 protected static function mirrorDataEntityFields(): array
1272 {
1273 return [
1274 'ID' => [
1275 'primary' => true,
1276 'field' => 'messageId',
1277 'set' => 'setMessageId',
1278 'get' => 'getMessageId',
1279 ],
1280 'CHAT_ID' => [
1281 'field' => 'chatId',
1282 'set' => 'setChatId',
1283 'get' => 'getChatId',
1284 ],
1285 'AUTHOR_ID' => [
1286 'field' => 'authorId',
1287 'set' => 'setAuthorId',
1288 'get' => 'getAuthorId',
1289 'loadFilter' => 'processChangeAuthorId',
1290 ],
1291 'FROM_USER_ID' => [
1292 'alias' => 'AUTHOR_ID',
1293 ],
1294 'MESSAGE' => [
1295 'field' => 'message',
1296 'set' => 'setMessage',
1297 'get' => 'getMessage',
1298 ],
1299 'MESSAGE_OUT' => [
1300 'field' => 'messageOut',
1301 'set' => 'setMessageOut',
1302 'get' => 'getMessageOut',
1303 ],
1304 'DATE_CREATE' => [
1305 'field' => 'dateCreate',
1306 'set' => 'setDateCreate',
1307 'get' => 'getDateCreate',
1308 'default' => 'getDefaultDateCreate',
1309 ],
1310 'MESSAGE_DATE' =>
1311 [
1312 'alias' => 'DATE_CREATE',
1313 ],
1314 'EMAIL_TEMPLATE' => [
1315 'field' => 'emailTemplate',
1316 'set' => 'setEmailTemplate',
1317 'get' => 'getEmailTemplate',
1318 ],
1319 'NOTIFY_TYPE' => [
1320 'field' => 'notifyType',
1321 'set' => 'setNotifyType',
1322 'get' => 'getNotifyType',
1323 'default' => 'getDefaultNotifyType',
1324 ],
1325 'NOTIFY_MODULE' => [
1326 'field' => 'notifyModule',
1327 'set' => 'setNotifyModule',
1328 'get' => 'getNotifyModule',
1329 'default' => 'getDefaultNotifyModule',
1330 ],
1331 'NOTIFY_EVENT' => [
1332 'field' => 'notifyEvent',
1333 'set' => 'setNotifyEvent',
1334 'get' => 'getNotifyEvent',
1335 'default' => 'getDefaultNotifyEvent',
1336 'loadFilter' => 'processChangeNotifyEvent',
1337 ],
1338 'NOTIFY_TAG' => [
1339 'field' => 'notifyTag',
1340 'set' => 'setNotifyTag',
1341 'get' => 'getNotifyTag',
1342 ],
1343 'NOTIFY_SUB_TAG' => [
1344 'field' => 'notifySubTag',
1345 'set' => 'setNotifySubTag',
1346 'get' => 'getNotifySubTag',
1347 ],
1348 'NOTIFY_TITLE' => [
1349 'field' => 'notifyTitle',
1350 'set' => 'setNotifyTitle',
1351 'get' => 'getNotifyTitle',
1352 ],
1353 'NOTIFY_LINK' => [
1354 'set' => 'setNotifyLink',
1355 'get' => 'getNotifyLink',
1356 ],
1357 'TITLE' => [
1358 'alias' => 'NOTIFY_TITLE',
1359 ],
1360 'NOTIFY_MESSAGE' => [
1361 'alias' => 'MESSAGE',
1362 ],
1363 'NOTIFY_MESSAGE_OUT' => [
1364 'alias' => 'MESSAGE_OUT',
1365 ],
1366 'NOTIFY_BUTTONS' => [
1367 'field' => 'notifyButtons',
1368 'set' => 'setNotifyButtons',
1369 'get' => 'getNotifyButtons',
1370 'saveFilter' => 'serializeNotifyButtons',
1371 'loadFilter' => 'unserializeNotifyButtons',
1372 ],
1373 'NOTIFY_READ' => [
1374 'field' => 'notifyRead',
1375 'set' => 'markNotifyRead',
1376 'get' => 'isNotifyRead',
1377 'default' => 'getDefaultNotifyRead',
1378 ],
1379 'NOTIFY_ANSWER' => [
1380 'set' => 'markNotifyAnswer',
1381 'get' => 'allowNotifyAnswer',
1382 ],
1383 'NOTIFY_FLASH' => [
1384 'set' => 'markNotifyFlash',
1385 'get' => 'isNotifyFlash',
1386 ],
1387 'NOTIFY_ONLY_FLASH' => [
1388 'alias' => 'NOTIFY_FLASH',
1389 ],
1390 'IMPORT_ID' => [
1391 'field' => 'importId',
1392 'set' => 'setImportId',
1393 'get' => 'getImportId',
1394 ],
1395 'SYSTEM' => [
1396 'set' => 'markAsSystem',
1397 'get' => 'isSystem',
1398 ],
1399 'PARAMS' => [
1400 'set' => 'setParams',
1401 'get' => 'getParams',
1402 ],
1403 'ATTACH' => [
1404 'set' => 'setAttach',
1405 'get' => 'getAttach',
1406 ],
1407 'FILES' => [
1408 'set' => 'setFiles',
1409 'get' => 'getFiles',
1410 ],
1411 'KEYBOARD' => [
1412 'set' => 'setKeyboard',
1413 'get' => 'getKeyboard',
1414 ],
1415 'MENU' => [
1416 'set' => 'setMenu',
1417 'get' => 'getMenu',
1418 ],
1419 'UUID' => [
1420 'set' => 'setUuid',
1421 'get' => 'getUuid',
1422 ],
1423 'MESSAGE_UUID' => [
1424 'alias' => 'UUID',
1425 ],
1426 'TEMPLATE_ID' => [
1427 'alias' => 'UUID',
1428 ],
1429 'FILE_TEMPLATE_ID' => [
1430 'set' => 'setFileUuid',
1431 'get' => 'getFileUuid',
1432 ],
1433 'PUSH_MESSAGE' => [
1434 'set' => 'setPushMessage',
1435 'get' => 'getPushMessage',
1436 ],
1437 'MESSAGE_PUSH' => [
1438 'alias' => 'PUSH_MESSAGE'
1439 ],
1440 'PUSH_PARAMS' => [
1441 'set' => 'setPushParams',
1442 'get' => 'getPushParams',
1443 ],
1444 'EXTRA_PARAMS' => [
1445 'alias' => 'PUSH_PARAMS'
1446 ],
1447 'PUSH_APP_ID' => [
1448 'set' => 'setPushAppId',
1449 'get' => 'getPushAppId',
1450 ],
1451 ];
1452 }
1453
1457 public static function getDataClass(): string
1458 {
1459 return MessageTable::class;
1460 }
1461
1465 public function getPrimaryId(): ?int
1466 {
1467 return $this->getMessageId();
1468 }
1469
1474 public function setPrimaryId(int $primaryId): self
1475 {
1476 return $this->setMessageId($primaryId);
1477 }
1478
1479 //endregion
1480
1481 public function markAsFavorite(): Result
1482 {
1483 $favoriteMessageService = new FavoriteService();
1484 $favoriteMessageService->setContext($this->context);
1485
1486 return $favoriteMessageService->markMessageAsFavorite($this);
1487 }
1488
1489 public function unmarkAsFavorite(): Result
1490 {
1491 $favoriteMessageService = new FavoriteService();
1492 $favoriteMessageService->setContext($this->context);
1493
1494 return $favoriteMessageService->unmarkMessageAsFavorite($this);
1495 }
1496
1497 public function pin(): Result
1498 {
1499 $pinService = new PinService();
1500 $pinService->setContext($this->context);
1501
1502 return $pinService->pinMessage($this);
1503 }
1504
1505 public function unpin(): Result
1506 {
1507 $pinService = new PinService();
1508 $pinService->setContext($this->context);
1509
1510 return $pinService->unpinMessage($this);
1511 }
1512
1513 public function mark(): Result
1514 {
1515 $result = new Result();
1516
1517 $isSuccessMark = Recent::unread(
1518 $this->getChat()->getDialogId(),
1519 true,
1520 $this->getContext()->getUserId(),
1521 $this->getId()
1522 );
1523
1524 if (!$isSuccessMark)
1525 {
1526 $result->addError(new Im\V2\Message\MessageError(Im\V2\Message\MessageError::MARK_FAILED));
1527 }
1528
1529 return $result;
1530 }
1531
1532 public function addToReminder(DateTime $dateRemind): Result
1533 {
1534 $reminderService = new Link\Reminder\ReminderService();
1535 $reminderService->setContext($this->context);
1536
1537 return $reminderService->addMessageToReminders($this, $dateRemind);
1538 }
1539
1540 public function getPreviewMessage(?int $messageSize = 200): string
1541 {
1542 $previewMessage = trim($this->getFormattedMessage());
1543 $hasFiles = $this->hasFiles();
1544 $hasAttach = mb_strpos($previewMessage, '[ATTACH=') !== false;
1545
1546 if ($this->getRegistry() instanceof MessageCollection)
1547 {
1548 $this->getRegistry()->fillFiles();
1549 }
1550
1551 if ($hasFiles)
1552 {
1553 $files = $this->getFiles();
1554 foreach ($files as $file)
1555 {
1556 $hasFiles = true;
1557 $previewMessage .= " [{$file->getDiskFile()->getName()}]";
1558 }
1559 }
1560
1561 $previewMessage = preg_replace(
1562 "/\[ATTACH=([0-9]{1,})\]/i",
1563 " [".Loc::getMessage('IM_MESSAGE_ATTACH')."] ",
1564 $previewMessage
1565 );
1566 $previewMessage = preg_replace(
1567 '#\-{54}.+?\-{54}#s',
1568 " [".Loc::getMessage('IM_MESSAGE_QUOTE')."] ",
1569 str_replace(["#BR#"], [" "], $previewMessage)
1570 );
1571 $previewMessage = preg_replace(
1572 '/^(>>(.*)(\n)?)/mi',
1573 " [".Loc::getMessage('IM_MESSAGE_QUOTE')."] ",
1574 str_replace(["#BR#"], [" "], $previewMessage)
1575 );
1576
1577 if (!$hasFiles && !$hasAttach)
1578 {
1579 if ($this->getParams()->isSet(Params::ATTACH))
1580 {
1581 $previewMessage .= " [".Loc::getMessage('IM_MESSAGE_ATTACH')."]";
1582 }
1583 }
1584
1585 if ($messageSize !== null)
1586 {
1587 $dots = mb_strlen($previewMessage) >= $messageSize ? '...' : '';
1588 $previewMessage = mb_substr($previewMessage, 0, $messageSize - 1) . $dots;
1589 }
1590
1591 return $previewMessage;
1592 }
1593
1594 public function getForPush(?int $messageSize = 200): string
1595 {
1596 if ($this->getRegistry() instanceof MessageCollection)
1597 {
1598 $this->getRegistry()->fillFiles();
1599 }
1600
1601 $files = [];
1602
1603 foreach ($this->getFiles() as $file)
1604 {
1605 $files[] = ['name' => $file->getDiskFile()->getName()];
1606 }
1607
1608 $message = ['MESSAGE' => $this->getMessage(), 'FILES' => $files];
1609 $text = \CIMMessenger::PrepareParamsForPush($message);
1610
1611 if ($messageSize !== null)
1612 {
1613 $dots = mb_strlen($text) >= $messageSize ? '...' : '';
1614 $text = mb_substr($text, 0, $messageSize - 1) . $dots;
1615 }
1616
1617 return $text;
1618 }
1619
1620 public function hasAccess(?int $userId = null): bool
1621 {
1622 $userId ??= $this->getContext()->getUserId();
1623 $chat = $this->getChat();
1624
1625 return $this->getId() && $chat->hasAccess($userId) && $chat->getStartId($userId) <= $this->getId();
1626 }
1627
1628 public static function getRestEntityName(): string
1629 {
1630 return 'message';
1631 }
1632
1633 public function getUserIds(): array
1634 {
1635 $userIds = $this->getUserIdsFromMention();
1636
1637 if ($this->getAuthorId() !== 0)
1638 {
1639 $userIds[$this->getAuthorId()] = $this->getAuthorId();
1640 }
1641
1642 if ($this->getParams()->isSet(Params::FORWARD_USER_ID))
1643 {
1644 $userId = (int)$this->getParams()->get(Params::FORWARD_USER_ID)->getValue();
1645 $userIds[$userId] = $userId;
1646 }
1647
1648 return $userIds;
1649 }
1650
1651 protected function getUserIdsFromMention(): array
1652 {
1653 if (isset($this->userIdsFromMention))
1654 {
1655 return $this->userIdsFromMention;
1656 }
1657
1658 $this->userIdsFromMention = [];
1659 if (preg_match_all("/\[USER=([0-9]+)( REPLACE)?](.*?)\[\/USER]/i", $this->getParsedMessage(), $matches))
1660 {
1661 foreach ($matches[1] as $userId)
1662 {
1663 $this->userIdsFromMention[(int)$userId] = (int)$userId;
1664 }
1665 }
1666
1667 return $this->userIdsFromMention;
1668 }
1669
1670 public function getEnrichedParams(): Params
1671 {
1672 $params = clone $this->getParams();
1673
1674 $url = $this->getUrl();
1675 if (isset($url))
1676 {
1677 $params->get(Params::ATTACH)->addValue($url->getUrlAttach());
1678 }
1679
1680 if ($this->isCompletelyEmpty())
1681 {
1682 $params->get(Params::IS_DELETED)->setValue(true);
1683 }
1684
1685 return $params;
1686 }
1687
1688 public function isCompletelyEmpty(): bool
1689 {
1690 return (
1691 $this->getParsedMessage() === ''
1692 && !$this->getParams()->isSet(Params::FILE_ID)
1693 && !$this->getParams()->isSet(Params::KEYBOARD)
1694 && !$this->getParams()->isSet(Params::ATTACH)
1695 );
1696 }
1697
1698 public function getContextId(): string
1699 {
1700 $chat = $this->getChat();
1701
1702 if ($chat instanceof Im\V2\Chat\PrivateChat)
1703 {
1704 $userIds = $chat->getRelations()->getUserIds();
1705 $implodeUserIds = implode(':', $userIds);
1706
1707 return "{$implodeUserIds}/{$this->getMessageId()}";
1708 }
1709
1710 return "{$chat->getDialogId()}/{$this->getMessageId()}";
1711 }
1712
1713 protected function getContextTag(): string
1714 {
1715 return "#{$this->getContextId()}";
1716 }
1717
1718 public function isForward(): bool
1719 {
1720 return $this->getParams()->isSet(Params::FORWARD_ID)
1721 && $this->getParams()->isSet(Params::FORWARD_CONTEXT_ID)
1722 ;
1723 }
1724
1725 protected function getForwardInfo(): ?array
1726 {
1727 if (!$this->isForward())
1728 {
1729 return null;
1730 }
1731
1732 return [
1733 'id' => $this->getParams()->get(Params::FORWARD_CONTEXT_ID)->getValue(),
1734 'userId' => (int)$this->getParams()->get(Params::FORWARD_USER_ID)->getValue(),
1735 ];
1736 }
1737
1742 public function toRestFormat(array $option = []): array
1743 {
1744 $dateCreate = $this->getDateCreate();
1745 $authorId = $this->getNotifyEvent() === Notify::EVENT_SYSTEM ? 0 : $this->getAuthorId();
1746 $onlyCommonRest = [
1747 'id' => $this->getId(),
1748 'chat_id' => $this->getChatId(),
1749 'author_id' => $authorId,
1750 'date' => isset($dateCreate) ? $dateCreate->format('c') : null,
1751 'text' => $this->getFormattedMessage(),
1752 'isSystem' => $this->isSystem(),
1753 'replaces' => $this->getReplaceMap(),
1754 'uuid' => $this->getUuid(),
1755 'forward' => $this->getForwardInfo(),
1756 'params' => $this->getEnrichedParams()->toRestFormat(),
1757 ];
1758 $rest = $onlyCommonRest;
1759
1760 if (!isset($option['MESSAGE_ONLY_COMMON_FIELDS']) || $option['MESSAGE_ONLY_COMMON_FIELDS'] === false)
1761 {
1762 $rest = array_merge($onlyCommonRest, [
1763 'unread' => $this->isUnread(),
1764 'viewed' => $this->isViewed(),
1765 'viewedByOthers' => $this->isViewedByOthers(),
1766 ]);
1767 }
1768
1769 return $rest;
1770 }
1771
1776 public function generateUrlPreview(): void
1777 {
1778 if ($this->getMessage())
1779 {
1780 $urls = UrlItem::getUrlsFromText($this->getMessage());
1781 foreach ($urls as $url)
1782 {
1783 $metadata = UrlPreview::getMetadataByUrl($url, true, false);
1784 if ($metadata !== false)
1785 {
1786 $urlItem = UrlItem::initByMetadata($metadata);
1787 if ($urlItem->getId())
1788 {
1789 $this->getParams()->get(Params::URL_ID)->addValue($urlItem->getId());
1790 $this->getParams()->get(Params::ATTACH)->addValue($urlItem->getUrlAttach());
1791
1792 // check if message contains only link
1793 if ($urlItem->isStaticUrl())
1794 {
1795 $staticUrl = [$url];
1796 if (mb_substr($url, -1) == '/')
1797 {
1798 $staticUrl[] = mb_substr($url, 0, -1);
1799 }
1800 $checkMessage = trim(str_replace($staticUrl, '', $this->getMessage()));
1801
1802 if (empty($checkMessage))
1803 {
1804 $this->getParams()->get(Params::URL_ONLY)->setValue(true);
1805 }
1806 }
1807 }
1808 }
1809 }
1810 }
1811 }
1812
1817 public function parseDates(): self
1818 {
1819 if ($this->getMessage())
1820 {
1821 $dateConvertResult = Text::getDateConverterParams($this->getMessage());
1822 foreach ($dateConvertResult as $row)
1823 {
1824 $this->getParams()->get(Params::DATE_TEXT)->addValue($row->getText());
1825 $this->getParams()->get(Params::DATE_TS)->addValue($row->getDate()->getTimestamp());
1826 }
1827 }
1828
1829 return $this;
1830 }
1831
1836 public function checkEmoji(): self
1837 {
1838 if ($this->getMessage())
1839 {
1840 if (Text::isOnlyEmoji($this->getMessage()))
1841 {
1842 $this->getParams()->get(Params::LARGE_FONT)->setValue(true);
1843 }
1844 }
1845
1846 return $this;
1847 }
1848
1849 public function autocompleteParams(bool $urlPreview): self
1850 {
1851 $this->getParams()->get(Params::LARGE_FONT)->setValue(Text::isOnlyEmoji($this->getMessage() ?? ''));
1852 $dateText = [];
1853 $dateTs = [];
1854 $urlIds = [];
1855 $isUrlOnly = false;
1856 if ($urlPreview)
1857 {
1858 $results = Text::getDateConverterParams($this->getMessage() ?? '');
1859 foreach ($results as $result)
1860 {
1861 $dateText[] = $result->getText();
1862 $dateTs[] = $result->getDate()->getTimestamp();
1863 }
1864
1865 $url = UrlItem::getByMessage($this);
1866 if (isset($url))
1867 {
1868 if ($url->getId() !== null)
1869 {
1870 $urlIds[] = $url->getId();
1871 }
1872 $this->setUrl($url);
1873 $isUrlOnly = $this->isUrlOnly($url);
1874 }
1875 }
1876 $this->getParams()->get(Params::DATE_TEXT)->setValue($dateText);
1877 $this->getParams()->get(Params::DATE_TS)->setValue($dateTs);
1878 $this->getParams()->get(Params::URL_ID)->setValue($urlIds);
1879 $this->getParams()->get(Params::URL_ONLY)->setValue($isUrlOnly);
1880
1881 return $this;
1882 }
1883
1884 private function isUrlOnly(?UrlItem $url): bool
1885 {
1886 if ($url === null)
1887 {
1888 return false;
1889 }
1890
1891 if (!$url->isStaticUrl())
1892 {
1893 return false;
1894 }
1895
1896 $messageWithoutUrl = str_replace($url->getUrl(), '', $this->getMessage() ?? '');
1897
1898 return trim($messageWithoutUrl) === '';
1899 }
1900
1905 public function updateSearchIndex(): void
1906 {
1907 if ($this->getMessageId())
1908 {
1909 MessageTable::indexRecord($this->getMessageId());
1910 }
1911 }
1912
1917 public static function loadPhrases(): void
1918 {
1919 Loc::loadMessages(__FILE__);
1920 }
1921
1922 public function deleteSoft(): Result
1923 {
1924 $service = new Im\V2\Message\Delete\DeleteService($this);
1925 $service->setMode(Im\V2\Message\Delete\DeleteService::MODE_SOFT);
1926 return $service->delete();
1927 }
1928
1929 public function deleteHard(): Result
1930 {
1931 $service = new Im\V2\Message\Delete\DeleteService($this);
1932 $service->setMode(Im\V2\Message\Delete\DeleteService::MODE_HARD);
1933 return $service->delete();
1934 }
1935
1936 public function deleteComplete(): Result
1937 {
1938 $service = new Im\V2\Message\Delete\DeleteService($this);
1939 $service->setMode(Im\V2\Message\Delete\DeleteService::MODE_COMPLETE);
1940 return $service->delete();
1941 }
1942}
static hasAccess($chatId)
Definition chat.php:445
static validate(string $uuid)
Definition Uuid.php:87
const EVENT_PRIVATE_SYSTEM
Definition notify.php:15
const EVENT_DEFAULT
Definition notify.php:11
const EVENT_SYSTEM
Definition notify.php:12
static unread($dialogId, $unread, $userId=null, ?int $markedId=null)
Definition recent.php:1308
static getDateConverterParams($text)
Definition text.php:215
static isOnlyEmoji($text)
Definition text.php:229
static getInstance($userId=null)
Definition user.php:44
static initByDiskFilesIds(array $diskFilesIds, ?int $chatId=null)
get(string $paramName)
Definition Params.php:796
loadByMessageId(int $messageId)
Definition Params.php:435
markAsImportant(?bool $isImportant=true)
Definition Message.php:253
static getRestEntityName()
Definition Message.php:1628
setEmailTemplate(?string $value)
Definition Message.php:1008
setPrimaryId(int $primaryId)
Definition Message.php:1474
autocompleteParams(bool $urlPreview)
Definition Message.php:1849
markNotifyRead(?bool $value)
Definition Message.php:1162
setNotifyType(?int $value)
Definition Message.php:1019
toRestFormat(array $option=[])
Definition Message.php:1742
setMessage(?string $value)
Definition Message.php:894
setFileUuid(?string $uuid)
Definition Message.php:555
setNotifyModule(?string $value)
Definition Message.php:1038
getQuotedMessage(?int $messageSize=null)
Definition Message.php:939
setPushAppId(?string $message)
Definition Message.php:1252
setNotifyLink(?string $value)
Definition Message.php:1126
setPushParams(?array $params)
Definition Message.php:1236
setBotId(int $botId)
Definition Message.php:436
getPopupData(array $excludedList=[])
Definition Message.php:784
__construct($source=null)
Definition Message.php:175
getPreviewMessage(?int $messageSize=200)
Definition Message.php:1540
setKeyboard($keyboard)
Definition Message.php:447
processChangeAuthorId(int $authorId)
Definition Message.php:830
setUrl(?UrlItem $url)
Definition Message.php:346
setUnread(bool $isUnread)
Definition Message.php:370
getParams(bool $disallowLazyLoad=false)
Definition Message.php:313
addToReminder(DateTime $dateRemind)
Definition Message.php:1532
string $formattedMessage
Definition Message.php:71
setChat(Chat $chat)
Definition Message.php:861
setImportantFor(array $importantFor)
Definition Message.php:265
fillFiles(FileCollection $files)
Definition Message.php:618
setNotifyTag(?string $value)
Definition Message.php:1093
getForPush(?int $messageSize=200)
Definition Message.php:1594
setImportId(?int $value)
Definition Message.php:1200
setMessageId(int $messageId)
Definition Message.php:806
setViewedByOthers(bool $isViewedByOthers)
Definition Message.php:417
DateTime $dateCreate
Definition Message.php:77
markNotifyAnswer(?bool $value)
Definition Message.php:1178
Im V2 Message Reaction ReactionMessage $reactions
Definition Message.php:144
serializeNotifyButtons($value)
Definition Message.php:1152
markNotifyFlash(?bool $value)
Definition Message.php:1189
setNotifyEvent(?string $notifyEvent)
Definition Message.php:1059
setNotifySubTag(?string $value)
Definition Message.php:1104
hasAccess(?int $userId=null)
Definition Message.php:1620
setMessageOut(?string $value)
Definition Message.php:966
setViewed(bool $isViewed)
Definition Message.php:390
FileCollection $files
Definition Message.php:142
setForwardUuid(?string $forwardUuid)
Definition Message.php:277
setReactions(Im\V2\Message\Reaction\ReactionMessage $reactions)
Definition Message.php:658
setPushMessage(?string $message)
Definition Message.php:1220
setNotifyTitle(?string $value)
Definition Message.php:1115
array $userIdsFromMention
Definition Message.php:64
setUuid(?string $uuid)
Definition Message.php:520
addFile(Im\V2\Entity\File\FileItem $file)
Definition Message.php:625
setChatId(int $value)
Definition Message.php:855
unserializeNotifyButtons($value)
Definition Message.php:1157
setAuthorId(int $authorId)
Definition Message.php:821
markAsSystem(bool $flag)
Definition Message.php:219
static mirrorDataEntityFields()
Definition Message.php:1271
processChangeNotifyEvent(?string $notifyEvent)
Definition Message.php:1068
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
getRegistry()
setRegistry(Registry $registry)