mirror of
https://github.com/friendica/friendica
synced 2025-02-21 08:46:48 +00:00
Extract Transmitter::filterReceiverData() as own method
This commit is contained in:
parent
db949270f5
commit
befb4796f9
1 changed files with 25 additions and 18 deletions
|
@ -805,25 +805,45 @@ class Transmitter
|
|||
}
|
||||
}
|
||||
|
||||
$data = self::filterReceiverData($data, $item['author-link']);
|
||||
|
||||
$receivers = ['to' => array_values($data['to']), 'cc' => array_values($data['cc']), 'bto' => array_values($data['bto']), 'bcc' => array_values($data['bcc']), 'audience' => array_values($data['audience'])];
|
||||
|
||||
if (!$blindcopy) {
|
||||
unset($receivers['bto']);
|
||||
unset($receivers['bcc']);
|
||||
}
|
||||
|
||||
if (!$blindcopy && count($receivers['audience']) == 1) {
|
||||
$receivers['audience'] = $receivers['audience'][0];
|
||||
} elseif (!$receivers['audience']) {
|
||||
unset($receivers['audience']);
|
||||
}
|
||||
|
||||
return $receivers;
|
||||
}
|
||||
|
||||
private static function filterReceiverData(array $data, string $author_link): array
|
||||
{
|
||||
$data['to'] = array_unique($data['to']);
|
||||
$data['cc'] = array_unique($data['cc']);
|
||||
$data['bto'] = array_unique($data['bto']);
|
||||
$data['bcc'] = array_unique($data['bcc']);
|
||||
$data['audience'] = array_unique($data['audience']);
|
||||
|
||||
if (($key = array_search($item['author-link'], $data['to'])) !== false) {
|
||||
if (($key = array_search($author_link, $data['to'])) !== false) {
|
||||
unset($data['to'][$key]);
|
||||
}
|
||||
|
||||
if (($key = array_search($item['author-link'], $data['cc'])) !== false) {
|
||||
if (($key = array_search($author_link, $data['cc'])) !== false) {
|
||||
unset($data['cc'][$key]);
|
||||
}
|
||||
|
||||
if (($key = array_search($item['author-link'], $data['bto'])) !== false) {
|
||||
if (($key = array_search($author_link, $data['bto'])) !== false) {
|
||||
unset($data['bto'][$key]);
|
||||
}
|
||||
|
||||
if (($key = array_search($item['author-link'], $data['bcc'])) !== false) {
|
||||
if (($key = array_search($author_link, $data['bcc'])) !== false) {
|
||||
unset($data['bcc'][$key]);
|
||||
}
|
||||
|
||||
|
@ -857,20 +877,7 @@ class Transmitter
|
|||
}
|
||||
}
|
||||
|
||||
$receivers = ['to' => array_values($data['to']), 'cc' => array_values($data['cc']), 'bto' => array_values($data['bto']), 'bcc' => array_values($data['bcc']), 'audience' => array_values($data['audience'])];
|
||||
|
||||
if (!$blindcopy) {
|
||||
unset($receivers['bto']);
|
||||
unset($receivers['bcc']);
|
||||
}
|
||||
|
||||
if (!$blindcopy && count($receivers['audience']) == 1) {
|
||||
$receivers['audience'] = $receivers['audience'][0];
|
||||
} elseif (!$receivers['audience']) {
|
||||
unset($receivers['audience']);
|
||||
}
|
||||
|
||||
return $receivers;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue