mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-19 06:47:03 +00:00
Continued:
- used empty() instead of isset() - PR - @TODO must be with 3 slashes if not in comment block for some IDEs being used - added some empty lines Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
parent
2ab82ad084
commit
cbd18c5d99
1 changed files with 24 additions and 3 deletions
|
@ -223,7 +223,7 @@ function mailstream_decode_subject($subject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mailstream_subject(array $item) {
|
function mailstream_subject(array $item) {
|
||||||
if (isset($item['title'])) {
|
if (!empty($item['title'])) {
|
||||||
return mailstream_decode_subject($item['title']);
|
return mailstream_decode_subject($item['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,44 +231,60 @@ function mailstream_subject(array $item) {
|
||||||
// Don't look more than 100 levels deep for a subject, in case of loops
|
// Don't look more than 100 levels deep for a subject, in case of loops
|
||||||
for ($i = 0; ($i < 100) && $parent; $i++) {
|
for ($i = 0; ($i < 100) && $parent; $i++) {
|
||||||
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
|
$parent_item = Item::selectFirst(['thr-parent', 'title'], ['uri' => $parent]);
|
||||||
|
|
||||||
if (!DBM::is_result($parent_item)) {
|
if (!DBM::is_result($parent_item)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parent_item['thr-parent'] === $parent) {
|
if ($parent_item['thr-parent'] === $parent) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parent_item['title']) {
|
if ($parent_item['title']) {
|
||||||
return L10n::t('Re:') . ' ' . mailstream_decode_subject($parent_item['title']);
|
return L10n::t('Re:') . ' ' . mailstream_decode_subject($parent_item['title']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $parent_item['thr-parent'];
|
$parent = $parent_item['thr-parent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d",
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d",
|
||||||
intval($item['contact-id']), intval($item['uid']));
|
intval($item['contact-id']), intval($item['uid']));
|
||||||
|
|
||||||
|
/// @TODO If above statement fails, this will cause E_NOTICE-s
|
||||||
|
/// @TODO Also maybe directly use $r[0] instead of variable copy?
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
|
|
||||||
if ($contact['network'] === 'dfrn') {
|
if ($contact['network'] === 'dfrn') {
|
||||||
return L10n::t("Friendica post");
|
return L10n::t("Friendica post");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['network'] === 'dspr') {
|
if ($contact['network'] === 'dspr') {
|
||||||
return L10n::t("Diaspora post");
|
return L10n::t("Diaspora post");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['network'] === 'face') {
|
if ($contact['network'] === 'face') {
|
||||||
$text = mailstream_decode_subject($item['body']);
|
$text = mailstream_decode_subject($item['body']);
|
||||||
|
|
||||||
// For some reason these do show up in Facebook
|
// For some reason these do show up in Facebook
|
||||||
$text = preg_replace('/\xA0$/', '', $text);
|
$text = preg_replace('/\xA0$/', '', $text);
|
||||||
$subject = (strlen($text) > 150) ? (substr($text, 0, 140) . '...') : $text;
|
$subject = (strlen($text) > 150) ? (substr($text, 0, 140) . '...') : $text;
|
||||||
|
|
||||||
return preg_replace('/\\s+/', ' ', $subject);
|
return preg_replace('/\\s+/', ' ', $subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['network'] === 'feed') {
|
if ($contact['network'] === 'feed') {
|
||||||
return L10n::t("Feed item");
|
return L10n::t("Feed item");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['network'] === 'mail') {
|
if ($contact['network'] === 'mail') {
|
||||||
return L10n::t("Email");
|
return L10n::t("Email");
|
||||||
}
|
}
|
||||||
|
|
||||||
return L10n::t("Friendica Item");
|
return L10n::t("Friendica Item");
|
||||||
}
|
}
|
||||||
|
|
||||||
function mailstream_send(App $a, $message_id, array $item, $user) {
|
function mailstream_send(App $a, $message_id, array $item, $user) {
|
||||||
if (!isset($item['visible'])) {
|
if (empty($item['visible'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,20 +292,25 @@ function mailstream_send(App $a, $message_id, array $item, $user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO Isn't there a better way?
|
/// @TODO Isn't there a better way?
|
||||||
require_once dirname(__FILE__) . '/phpmailer/class.phpmailer.php';
|
require_once dirname(__FILE__) . '/phpmailer/class.phpmailer.php';
|
||||||
|
|
||||||
$attachments = [];
|
$attachments = [];
|
||||||
mailstream_do_images($a, $item, $attachments);
|
mailstream_do_images($a, $item, $attachments);
|
||||||
$frommail = Config::get('mailstream', 'frommail');
|
$frommail = Config::get('mailstream', 'frommail');
|
||||||
|
|
||||||
if ($frommail == "") {
|
if ($frommail == "") {
|
||||||
$frommail = 'friendica@localhost.local';
|
$frommail = 'friendica@localhost.local';
|
||||||
}
|
}
|
||||||
|
|
||||||
$address = PConfig::get($item['uid'], 'mailstream', 'address');
|
$address = PConfig::get($item['uid'], 'mailstream', 'address');
|
||||||
|
|
||||||
if (!$address) {
|
if (!$address) {
|
||||||
$address = $user['email'];
|
$address = $user['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$mail = new PHPmailer;
|
$mail = new PHPmailer;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$mail->XMailer = 'Friendica Mailstream Addon';
|
$mail->XMailer = 'Friendica Mailstream Addon';
|
||||||
$mail->SetFrom($frommail, mailstream_sender($item));
|
$mail->SetFrom($frommail, mailstream_sender($item));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue