some more robust mailstream stuff

This commit is contained in:
Matthew Exon 2023-12-26 16:34:57 +00:00
parent 2728f8a839
commit a30d850ff1

View file

@ -118,9 +118,28 @@ function mailstream_send_hook(array $data)
return;
}
if ($item['deleted']) {
Logger::debug('mailstream_send_hook skipping deleted item', ['guid' => $item['guid']]);
return;
}
$user = User::getById($item['uid']);
if (empty($user)) {
Logger::error('mailstream_send_hook could not fund user', ['uid' => $item['uid']]);
Logger::error('mailstream_send_hook could not find user', ['uid' => $item['uid']]);
return;
}
$contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
if (!DBA::isResult($contact)) {
Logger::error('mailstream_send_hook could not find contact', ['guid' => $item['guid'], 'contact-id' => $item['contact-id']]);
return;
}
if ($contact['blocked']) {
Logger::error('mailstream_send_hook contact is blocked', ['guid' => $item['guid'], 'contact-id' => $item['contact-id']]);
return;
}
if (array_key_exists('ignored', $contact) && $contact['ignored']) {
Logger::error('mailstream_send_hook contact is ignored', ['guid' => $item['guid'], 'contact-id' => $item['contact-id']]);
return;
}
@ -143,7 +162,6 @@ function mailstream_send_hook(array $data)
function mailstream_post_hook(array &$item)
{
mailstream_check_version();
Logger::debug('@@@ mailstream_post_hook', ['item-uid' => $item['uid']]);
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'enabled')) {
Logger::debug('mailstream: not enabled for item ' . $item['id'] . ' uid ' . $item['uid']);