mirror of
https://github.com/friendica/friendica
synced 2025-04-28 02:30:16 +00:00
"post-reason" ends double usage of "post-type"
This commit is contained in:
parent
9a3a7793f0
commit
688e056ad1
13 changed files with 159 additions and 76 deletions
|
@ -198,31 +198,47 @@ class Processor
|
|||
|
||||
// image is the preview/thumbnail URL
|
||||
if (!empty($attach['image'])) {
|
||||
$trailing .= '[url=' . $attach['url'] . ']';
|
||||
$media = '[url=' . $attach['url'] . ']';
|
||||
$attach['url'] = $attach['image'];
|
||||
} else {
|
||||
$media = '';
|
||||
}
|
||||
|
||||
if (empty($attach['name'])) {
|
||||
$trailing .= '[img]' . $attach['url'] . '[/img]';
|
||||
$media .= '[img]' . $attach['url'] . '[/img]';
|
||||
} else {
|
||||
$trailing .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
|
||||
$media .= '[img=' . $attach['url'] . ']' . $attach['name'] . '[/img]';
|
||||
}
|
||||
|
||||
if (!empty($attach['image'])) {
|
||||
$trailing .= '[/url]';
|
||||
$media .= '[/url]';
|
||||
}
|
||||
|
||||
if ($item['post-type'] == Item::PT_IMAGE) {
|
||||
$leading .= $media;
|
||||
} else {
|
||||
$trailing .= $media;
|
||||
}
|
||||
} elseif ($filetype == 'audio') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$leading .= '[audio]' . $attach['url'] . "[/audio]\n";
|
||||
if ($item['post-type'] == Item::PT_AUDIO) {
|
||||
$leading .= '[audio]' . $attach['url'] . "[/audio]\n";
|
||||
} else {
|
||||
$trailing .= '[audio]' . $attach['url'] . "[/audio]\n";
|
||||
}
|
||||
} elseif ($filetype == 'video') {
|
||||
if (!empty($activity['source']) && strpos($activity['source'], $attach['url'])) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$leading .= '[video]' . $attach['url'] . "[/video]\n";
|
||||
if ($item['post-type'] == Item::PT_VIDEO) {
|
||||
$leading .= '[video]' . $attach['url'] . "[/video]\n";
|
||||
} else {
|
||||
$trailing .= '[video]' . $attach['url'] . "[/video]\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +266,7 @@ class Processor
|
|||
*/
|
||||
public static function updateItem($activity)
|
||||
{
|
||||
$item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity'], ['uri' => $activity['id']]);
|
||||
$item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type'], ['uri' => $activity['id']]);
|
||||
if (!DBA::isResult($item)) {
|
||||
Logger::warning('No existing item, item will be created', ['uri' => $activity['id']]);
|
||||
$item = self::createItem($activity);
|
||||
|
@ -336,6 +352,24 @@ class Processor
|
|||
$item['direction'] = Conversation::RELAY;
|
||||
}
|
||||
|
||||
if ($activity['object_type'] == 'as:Article') {
|
||||
$item['post-type'] = Item::PT_ARTICLE;
|
||||
} elseif ($activity['object_type'] == 'as:Audio') {
|
||||
$item['post-type'] = Item::PT_AUDIO;
|
||||
} elseif ($activity['object_type'] == 'as:Document') {
|
||||
$item['post-type'] = Item::PT_DOCUMENT;
|
||||
} elseif ($activity['object_type'] == 'as:Event') {
|
||||
$item['post-type'] = Item::PT_EVENT;
|
||||
} elseif ($activity['object_type'] == 'as:Image') {
|
||||
$item['post-type'] = Item::PT_IMAGE;
|
||||
} elseif ($activity['object_type'] == 'as:Page') {
|
||||
$item['post-type'] = Item::PT_PAGE;
|
||||
} elseif ($activity['object_type'] == 'as:Video') {
|
||||
$item['post-type'] = Item::PT_VIDEO;
|
||||
} else {
|
||||
$item['post-type'] = Item::PT_NOTE;
|
||||
}
|
||||
|
||||
$item['isForum'] = false;
|
||||
|
||||
if (!empty($activity['thread-completion'])) {
|
||||
|
@ -456,6 +490,7 @@ class Processor
|
|||
$item['verb'] = $verb;
|
||||
$item['thr-parent'] = $activity['object_id'];
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
unset($item['post-type']);
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
||||
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
|
||||
|
@ -629,34 +664,34 @@ class Processor
|
|||
$type = $activity['reception_type'][$receiver] ?? Receiver::TARGET_UNKNOWN;
|
||||
switch($type) {
|
||||
case Receiver::TARGET_TO:
|
||||
$item['post-type'] = Item::PT_TO;
|
||||
$item['post-reason'] = Item::PR_TO;
|
||||
break;
|
||||
case Receiver::TARGET_CC:
|
||||
$item['post-type'] = Item::PT_CC;
|
||||
$item['post-reason'] = Item::PR_CC;
|
||||
break;
|
||||
case Receiver::TARGET_BTO:
|
||||
$item['post-type'] = Item::PT_BTO;
|
||||
$item['post-reason'] = Item::PR_BTO;
|
||||
break;
|
||||
case Receiver::TARGET_BCC:
|
||||
$item['post-type'] = Item::PT_BCC;
|
||||
$item['post-reason'] = Item::PR_BCC;
|
||||
break;
|
||||
case Receiver::TARGET_FOLLOWER:
|
||||
$item['post-type'] = Item::PT_FOLLOWER;
|
||||
$item['post-reason'] = Item::PR_FOLLOWER;
|
||||
break;
|
||||
case Receiver::TARGET_ANSWER:
|
||||
$item['post-type'] = Item::PT_COMMENT;
|
||||
$item['post-reason'] = Item::PR_COMMENT;
|
||||
break;
|
||||
case Receiver::TARGET_GLOBAL:
|
||||
$item['post-type'] = Item::PT_GLOBAL;
|
||||
$item['post-reason'] = Item::PR_GLOBAL;
|
||||
break;
|
||||
default:
|
||||
$item['post-type'] = Item::PT_ARTICLE;
|
||||
$item['post-reason'] = Item::PR_NONE;
|
||||
}
|
||||
|
||||
if (!empty($activity['from-relay'])) {
|
||||
$item['post-type'] = Item::PT_RELAY;
|
||||
$item['post-reason'] = Item::PR_RELAY;
|
||||
} elseif (!empty($activity['thread-completion'])) {
|
||||
$item['post-type'] = Item::PT_FETCHED;
|
||||
$item['post-reason'] = Item::PR_FETCHED;
|
||||
}
|
||||
|
||||
if ($item['isForum'] ?? false) {
|
||||
|
|
|
@ -522,7 +522,7 @@ class Receiver
|
|||
return;
|
||||
}
|
||||
|
||||
$item['post-type'] = Item::PT_ANNOUNCEMENT;
|
||||
$item['post-reason'] = Item::PR_ANNOUNCEMENT;
|
||||
ActivityPub\Processor::postItem($object_data, $item);
|
||||
|
||||
$announce_object_data = self::processObject($activity);
|
||||
|
|
|
@ -2195,6 +2195,12 @@ class DFRN
|
|||
|
||||
$item["title"] = XML::getFirstNodeValue($xpath, "atom:title/text()", $entry);
|
||||
|
||||
if (!empty($item["title"])) {
|
||||
$item["post-type"] = Item::PT_ARTICLE;
|
||||
} else {
|
||||
$item["post-type"] = Item::PT_NOTE;
|
||||
}
|
||||
|
||||
$item["created"] = XML::getFirstNodeValue($xpath, "atom:published/text()", $entry);
|
||||
|
||||
$item["body"] = XML::getFirstNodeValue($xpath, "dfrn:env/text()", $entry);
|
||||
|
@ -2426,8 +2432,8 @@ class DFRN
|
|||
|
||||
if (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) {
|
||||
// Will be overwritten for sharing accounts in Item::insert
|
||||
if (empty($item['post-type']) && ($entrytype == DFRN::REPLY)) {
|
||||
$item['post-type'] = Item::PT_COMMENT;
|
||||
if (empty($item['post-reason']) && ($entrytype == DFRN::REPLY)) {
|
||||
$item['post-reason'] = Item::PR_COMMENT;
|
||||
}
|
||||
|
||||
$posted_id = Item::insert($item);
|
||||
|
@ -2588,7 +2594,7 @@ class DFRN
|
|||
$header["direction"] = $direction;
|
||||
|
||||
if ($direction === Conversation::RELAY) {
|
||||
$header['post-type'] = Item::PT_RELAY;
|
||||
$header['post-reason'] = Item::PR_RELAY;
|
||||
}
|
||||
|
||||
// Update the contact table if the data has changed
|
||||
|
|
|
@ -1536,11 +1536,11 @@ class Diaspora
|
|||
|
||||
// Will be overwritten for sharing accounts in Item::insert
|
||||
if ($fetched) {
|
||||
$datarray["post-type"] = Item::PT_FETCHED;
|
||||
$datarray["post-reason"] = Item::PR_FETCHED;
|
||||
} elseif ($datarray["uid"] == 0) {
|
||||
$datarray["post-type"] = Item::PT_GLOBAL;
|
||||
$datarray["post-reason"] = Item::PR_GLOBAL;
|
||||
} else {
|
||||
$datarray["post-type"] = Item::PT_COMMENT;
|
||||
$datarray["post-reason"] = Item::PR_COMMENT;
|
||||
}
|
||||
|
||||
$datarray["guid"] = $guid;
|
||||
|
@ -1553,6 +1553,7 @@ class Diaspora
|
|||
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray["object-type"] = Activity\ObjectType::COMMENT;
|
||||
$datarray["post-type"] = Item::PT_NOTE;
|
||||
|
||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray["source"] = $xml;
|
||||
|
@ -2737,8 +2738,10 @@ class Diaspora
|
|||
}
|
||||
|
||||
$datarray["object-type"] = Activity\ObjectType::IMAGE;
|
||||
$datarray["post-type"] = Item::PT_IMAGE;
|
||||
} else {
|
||||
$datarray["object-type"] = Activity\ObjectType::NOTE;
|
||||
$datarray["post-type"] = Item::PT_NOTE;
|
||||
|
||||
// Add OEmbed and other information to the body
|
||||
if (!self::isHubzilla($contact["url"])) {
|
||||
|
@ -2773,9 +2776,9 @@ class Diaspora
|
|||
$datarray["direction"] = $fetched ? Conversation::PULL : Conversation::PUSH;
|
||||
|
||||
if ($fetched) {
|
||||
$datarray["post-type"] = Item::PT_FETCHED;
|
||||
$datarray["post-reason"] = Item::PR_FETCHED;
|
||||
} elseif ($datarray["uid"] == 0) {
|
||||
$datarray["post-type"] = Item::PT_GLOBAL;
|
||||
$datarray["post-reason"] = Item::PR_GLOBAL;
|
||||
}
|
||||
|
||||
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
|
||||
|
|
|
@ -235,6 +235,7 @@ class Feed
|
|||
$header["private"] = Item::PUBLIC;
|
||||
$header["verb"] = Activity::POST;
|
||||
$header["object-type"] = Activity\ObjectType::NOTE;
|
||||
$header["post-type"] = Item::PT_ARTICLE;
|
||||
|
||||
$header["contact-id"] = $contact["id"] ?? 0;
|
||||
|
||||
|
@ -539,6 +540,10 @@ class Feed
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($item['title'])) {
|
||||
$item['post-type'] = Item::PT_NOTE;
|
||||
}
|
||||
|
||||
Logger::info('Stored feed', ['item' => $item]);
|
||||
|
||||
$notify = Item::isRemoteSelf($contact, $item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue