DBA::delete('item-delivery-data', ['iid' => $item['id']]);
- //if (!empty($item['iaid']) && !self::exists(['iaid' => $item['iaid'], 'deleted' => false])) {
- // DBA::delete('item-activity', ['id' => $item['iaid']], ['cascade' => false]);
- //}
+ // We don't delete the item-activity here, since we need some of the data for ActivityPub
+
if (!empty($item['icid']) && !self::exists(['icid' => $item['icid'], 'deleted' => false])) {
DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
}
return $tag_text;
}
- public static function tagArrayFromItemId($itemid)
+ public static function tagArrayFromItemId($itemid, $type = [TERM_HASHTAG, TERM_MENTION])
{
- $condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]];
+ $condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => $type];
$tags = DBA::select('term', ['type', 'term', 'url'], $condition);
if (!DBA::isResult($tags)) {
return [];
$data['totalItems'] = $count;
// When we hide our friends we will only show the pure number but don't allow more.
- $profile = Profile::getProfileForUser($owner['uid']);
+ $profile = Profile::getByUID($owner['uid']);
if (!empty($profile['hide-friends'])) {
return $data;
}
$data['totalItems'] = $count;
// When we hide our friends we will only show the pure number but don't allow more.
- $profile = Profile::getProfileForUser($owner['uid']);
+ $profile = Profile::getByUID($owner['uid']);
if (!empty($profile['hide-friends'])) {
return $data;
}
$permissions['to'][] = $actor;
- $elements = ['to', 'cc', 'bto', 'bcc'];
- foreach ($elements as $element) {
+ foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
if (empty($activity[$element])) {
continue;
}
$actor_profile = APContact::getProfileByURL($item['author-link']);
- $terms = Term::tagArrayFromItemId($item['id']);
+ $terms = Term::tagArrayFromItemId($item['id'], TERM_MENTION);
$contacts[$item['author-link']] = $item['author-link'];
$item_profile = APContact::getProfileByURL($item['owner-link']);
}
- $elements = ['to', 'cc', 'bto', 'bcc'];
- foreach ($elements as $element) {
+ foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
if (empty($permissions[$element])) {
continue;
}
{
$tags = [];
- $terms = Term::tagArrayFromItemId($item['id']);
+ $terms = Term::tagArrayFromItemId($item['id'], TERM_MENTION);
foreach ($terms as $term) {
if ($term['type'] == TERM_MENTION) {
$contact = Contact::getDetailsByURL($term['url']);
$followers = '';
}
- $elements = ['to', 'cc', 'bto', 'bcc'];
- foreach ($elements as $element) {
+ foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
if (empty($activity[$element])) {
continue;
}
- // The receiver can be an arror or a string
+ // The receiver can be an array or a string
if (is_string($activity[$element])) {
$activity[$element] = [$activity[$element]];
}