X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mailstream%2Fmailstream.php;h=d825979b840e22029ea6a55c91091f444325f629;hb=d86ad302e387c1666e1aae51d243395883466bd5;hp=d877f1eb86d60d0607ff72baf71ddde4133ee5ec;hpb=a50ca549996d9e90c3bb7b616675f2cb6b8d6a27;p=friendica-addons.git diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index d877f1eb..d825979b 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; +use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; @@ -121,9 +122,10 @@ function mailstream_send_hook(&$a, $data) } if (!mailstream_send($data['message_id'], $item, $user)) { - $delayed = date(DateTimeFormat::utc('now + 1 hour')); - $data['tries'] += 1; - Hook::fork(['priority' => PRIORITY_LOW, 'delayed' => $delayed], 'mailstream_send_hook', $data); + Logger::debug('mailstream_send_hook send failed, will retry', $data); + if (!Worker::defer()) { + Logger::error('mailstream_send_hook failed and could not defer', $data); + } } } @@ -489,52 +491,62 @@ function mailstream_addon_settings(&$a, &$s) $attachimg= DI::pConfig()->get(local_user(), 'mailstream', 'attachimg'); $template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/'); $s .= Renderer::replaceMacros($template, [ - '$enabled' => [ - 'mailstream_enabled', - DI::l10n()->t('Enabled'), - $enabled], - '$address' => [ - 'mailstream_address', - DI::l10n()->t('Email Address'), - $address, - DI::l10n()->t("Leave blank to use your account email address")], - '$nolikes' => [ - 'mailstream_nolikes', - DI::l10n()->t('Exclude Likes'), - $nolikes, - DI::l10n()->t("Check this to omit mailing \"Like\" notifications")], - '$attachimg' => [ - 'mailstream_attachimg', - DI::l10n()->t('Attach Images'), - $attachimg, - DI::l10n()->t("Download images in posts and attach them to the email. " . - "Useful for reading email while offline.")], - '$title' => DI::l10n()->t('Mail Stream Settings'), - '$submit' => DI::l10n()->t('Save Settings')]); + '$enabled' => [ + 'mailstream_enabled', + DI::l10n()->t('Enabled'), + $enabled + ], + '$address' => [ + 'mailstream_address', + DI::l10n()->t('Email Address'), + $address, + DI::l10n()->t("Leave blank to use your account email address") + ], + '$nolikes' => [ + 'mailstream_nolikes', + DI::l10n()->t('Exclude Likes'), + $nolikes, + DI::l10n()->t("Check this to omit mailing \"Like\" notifications") + ], + '$attachimg' => [ + 'mailstream_attachimg', + DI::l10n()->t('Attach Images'), + $attachimg, + DI::l10n()->t("Download images in posts and attach them to the email. " . + "Useful for reading email while offline.") + ], + '$title' => DI::l10n()->t('Mail Stream Settings'), + '$submit' => DI::l10n()->t('Save Settings')]); } /** * Process data submitted to user's mailstream features form + * @param \Friendica\App $a + * @param array $post POST data */ -function mailstream_addon_settings_post() +function mailstream_addon_settings_post(\Friendica\App $a, array $post) { - if ($_POST['mailstream_address'] != "") { - DI::pConfig()->set(local_user(), 'mailstream', 'address', $_POST['mailstream_address']); + if (!local_user() || empty($post['mailstream-submit'])) { + return; + } + + if ($post['mailstream_address'] != "") { + DI::pConfig()->set(local_user(), 'mailstream', 'address', $post['mailstream_address']); } else { DI::pConfig()->delete(local_user(), 'mailstream', 'address'); } - if ($_POST['mailstream_nolikes']) { - DI::pConfig()->set(local_user(), 'mailstream', 'nolikes', $_POST['mailstream_enabled']); + if ($post['mailstream_nolikes']) { + DI::pConfig()->set(local_user(), 'mailstream', 'nolikes', $post['mailstream_enabled']); } else { DI::pConfig()->delete(local_user(), 'mailstream', 'nolikes'); } - if ($_POST['mailstream_enabled']) { - DI::pConfig()->set(local_user(), 'mailstream', 'enabled', $_POST['mailstream_enabled']); + if ($post['mailstream_enabled']) { + DI::pConfig()->set(local_user(), 'mailstream', 'enabled', $post['mailstream_enabled']); } else { DI::pConfig()->delete(local_user(), 'mailstream', 'enabled'); } - if ($_POST['mailstream_attachimg']) { - DI::pConfig()->set(local_user(), 'mailstream', 'attachimg', $_POST['mailstream_attachimg']); + if ($post['mailstream_attachimg']) { + DI::pConfig()->set(local_user(), 'mailstream', 'attachimg', $post['mailstream_attachimg']); } else { DI::pConfig()->delete(local_user(), 'mailstream', 'attachimg'); }