15 return sprintf(
'/mail/message/%u', $messageId);
20 return self::getMessageStorage()->getMessage($id);
40 $mailboxId = MailMessageTable::getList([
49 if(isset($mailboxId[0][
'MAILBOX_ID']))
51 return (
int)$mailboxId[0][
'MAILBOX_ID'];
57 private static function getMessageUrl(
int $messageId,
string $entityType,
int $entityId, ?
int $userId =
null): ?string
59 $message = MailMessageTable::getList([
62 'MAILBOX_EMAIL' =>
'MAILBOX.EMAIL',
63 'MAILBOX_NAME' =>
'MAILBOX.NAME',
64 'MAILBOX_LOGIN' =>
'MAILBOX.LOGIN',
77 '=MAILBOX_ID' => $message[
'MAILBOX_ID'],
78 '=MESSAGE_ID' => $message[
'ID'],
84 $filter[
'=ENTITY_TYPE'] = $entityType;
85 $filter[
'=ENTITY_ID'] = $entityId;
88 $access = MessageAccessTable::getList([
98 \Bitrix\Mail\Helper\Message::prepare($message);
100 $signer = new \Bitrix\Main\Security\Sign\Signer(
new \
Bitrix\Main\Security\Sign\HmacAlgorithm(
'md5'));
102 $message[
'__href'] = \CHTTP::urlAddParams(
105 'mail_uf_message_token' => sprintf(
116 return $message[
'__href'];
121 $message = MailMessageTable::getList([
126 '=ID' => $mailMessageId,
133 MessageAccessTable::add([
135 'MAILBOX_ID' => $message[
'MAILBOX_ID'],
136 'MESSAGE_ID' => $mailMessageId,
137 'ENTITY_UF_ID' =>
'0',
138 'ENTITY_TYPE' => $entityType,
139 'ENTITY_ID' => $entityId,
152 $messageAccessQuery = MessageAccessTable::query()
159 '=ENTITY_TYPE' => MessageAccessTable::ENTITY_TYPE_TASKS_TASK,
160 '=ENTITY_ID' => $taskId,
163 while ($messageAccess = $messageAccessQuery->fetch())
165 $messageId = $messageAccess[
'MESSAGE_ID'];
166 $mailboxId = $messageAccess[
'MAILBOX_ID'];
167 MessageAccessTable::delete([
'TOKEN' => $messageAccess[
'TOKEN']]);
169 if (Loader::includeModule(
'pull'))
173 \CPullWatch::addToStack(
174 'mail_mailbox_' . $mailboxId,
176 'module_id' =>
'mail',
177 'command' =>
'messageBindingDeleted',
179 'messageId' => $messageId,
180 'mailboxId' => $mailboxId,
181 'entityType' => MessageAccessTable::ENTITY_TYPE_TASKS_TASK,
182 'entityId' => $taskId,
193 return new \Bitrix\Mail\Storage\Message();
static isMailboxOwner(int $mailboxId, int $userId)
static createToken($mailBoxId, $messageId, $entityType, $entityId, $ufId='0')
static getSaltByEntityType(string $entityType, int $entityId, ?int $userId=null)
const ENTITY_TYPE_CALENDAR_EVENT
const ENTITY_TYPE_IM_CHAT
static getMessageUrlForChat(int $messageId, int $chatId)
static getMessage(int $id)
static getDirectMessageUrl(int $messageId)
static getMessageUrlForCalendarEvent(int $messageId, int $eventId)
static getMailboxIdForMessage(int $messageId)
static provideAccessToMessage(int $mailMessageId, string $entityType, int $entityId, int $userId)
static onTaskDelete($taskId)