mirror of
https://github.com/friendica/friendica
synced 2025-04-26 17:50:11 +00:00
Move Activity/Namespaces defines to constants
This commit is contained in:
parent
978262a718
commit
07cea24430
34 changed files with 467 additions and 403 deletions
|
@ -2,11 +2,85 @@
|
|||
|
||||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\Protocol\Activity\Namespaces;
|
||||
|
||||
/**
|
||||
* Base class for the Activity namespace
|
||||
* Base class for the Activity constants and match method
|
||||
*/
|
||||
final class Activity
|
||||
{
|
||||
const LIKE = Namespaces::ACTIVITY_SCHEMA . 'like';
|
||||
|
||||
const DISLIKE = Namespaces::DFRN . '/dislike';
|
||||
const ATTEND = Namespaces::ZOT . '/activity/attendyes';
|
||||
const ATTENDNO = Namespaces::ZOT . '/activity/attendno';
|
||||
const ATTENDMAYBE = Namespaces::ZOT . '/activity/attendmaybe';
|
||||
const OBJ_HEART = Namespaces::DFRN . '/heart';
|
||||
|
||||
const FRIEND = Namespaces::ACTIVITY_SCHEMA . 'make-friend';
|
||||
const REQ_FRIEND = Namespaces::ACTIVITY_SCHEMA . 'request-friend';
|
||||
const UNFRIEND = Namespaces::ACTIVITY_SCHEMA . 'remove-friend';
|
||||
const FOLLOW = Namespaces::ACTIVITY_SCHEMA . 'follow';
|
||||
const UNFOLLOW = Namespaces::ACTIVITY_SCHEMA . 'stop-following';
|
||||
const JOIN = Namespaces::ACTIVITY_SCHEMA . 'join';
|
||||
const POST = Namespaces::ACTIVITY_SCHEMA . 'post';
|
||||
const UPDATE = Namespaces::ACTIVITY_SCHEMA . 'update';
|
||||
const TAG = Namespaces::ACTIVITY_SCHEMA . 'tag';
|
||||
const FAVORITE = Namespaces::ACTIVITY_SCHEMA . 'favorite';
|
||||
const UNFAVORITE = Namespaces::ACTIVITY_SCHEMA . 'unfavorite';
|
||||
const SHARE = Namespaces::ACTIVITY_SCHEMA . 'share';
|
||||
const DELETE = Namespaces::ACTIVITY_SCHEMA . 'delete';
|
||||
const ANNOUNCE = Namespaces::ACTIVITY2 . 'Announce';
|
||||
|
||||
const POKE = Namespaces::ZOT . '/activity/poke';
|
||||
|
||||
const OBJ_BOOKMARK = Namespaces::ACTIVITY_SCHEMA . 'bookmark';
|
||||
const OBJ_COMMENT = Namespaces::ACTIVITY_SCHEMA . 'comment';
|
||||
const OBJ_NOTE = Namespaces::ACTIVITY_SCHEMA . 'note';
|
||||
const OBJ_PERSON = Namespaces::ACTIVITY_SCHEMA . 'person';
|
||||
const OBJ_IMAGE = Namespaces::ACTIVITY_SCHEMA . 'image';
|
||||
const OBJ_PHOTO = Namespaces::ACTIVITY_SCHEMA . 'photo';
|
||||
const OBJ_VIDEO = Namespaces::ACTIVITY_SCHEMA . 'video';
|
||||
const OBJ_P_PHOTO = Namespaces::ACTIVITY_SCHEMA . 'profile-photo';
|
||||
const OBJ_ALBUM = Namespaces::ACTIVITY_SCHEMA . 'photo-album';
|
||||
const OBJ_EVENT = Namespaces::ACTIVITY_SCHEMA . 'event';
|
||||
const OBJ_GROUP = Namespaces::ACTIVITY_SCHEMA . 'group';
|
||||
const OBJ_TAGTERM = Namespaces::DFRN . '/tagterm';
|
||||
const OBJ_PROFILE = Namespaces::DFRN . '/profile';
|
||||
|
||||
const OBJ_QUESTION = 'http://activityschema.org/object/question';
|
||||
|
||||
/**
|
||||
* likes (etc.) can apply to other things besides posts. Check if they are post children,
|
||||
* in which case we handle them specially
|
||||
*
|
||||
* Hidden activities, which doesn't need to be shown
|
||||
*/
|
||||
const HIDDEN_ACTIVITIES = [
|
||||
Activity::LIKE, Activity::DISLIKE,
|
||||
Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE,
|
||||
Activity::FOLLOW,
|
||||
Activity::ANNOUNCE,
|
||||
];
|
||||
|
||||
/**
|
||||
* Checks if the given activity is a hidden activity
|
||||
*
|
||||
* @param string $activity The current activity
|
||||
*
|
||||
* @return bool True, if the activity is hidden
|
||||
*/
|
||||
public function isHidden(string $activity)
|
||||
{
|
||||
foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) {
|
||||
if ($this->match($activity, $hiddenActivity)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare activity uri. Knows about activity namespace.
|
||||
*
|
||||
|
@ -15,9 +89,10 @@ final class Activity
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function match(string $haystack, string $needle) {
|
||||
public function match(string $haystack, string $needle)
|
||||
{
|
||||
return (($haystack === $needle) ||
|
||||
((basename($needle) === $haystack) &&
|
||||
strstr($needle, NAMESPACE_ACTIVITY_SCHEMA)));
|
||||
strstr($needle, Namespaces::ACTIVITY_SCHEMA)));
|
||||
}
|
||||
}
|
||||
|
|
27
src/Protocol/Activity/Namespaces.php
Normal file
27
src/Protocol/Activity/Namespaces.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Protocol\Activity;
|
||||
|
||||
/**
|
||||
* Activity namespaces constants
|
||||
*/
|
||||
final class Namespaces
|
||||
{
|
||||
const ZOT = 'http://purl.org/zot';
|
||||
const DFRN = 'http://purl.org/macgirvin/dfrn/1.0';
|
||||
const THREAD = 'http://purl.org/syndication/thread/1.0';
|
||||
const TOMB = 'http://purl.org/atompub/tombstones/1.0';
|
||||
const ACTIVITY2 = 'https://www.w3.org/ns/activitystreams#';
|
||||
const ACTIVITY = 'http://activitystrea.ms/spec/1.0/';
|
||||
const ACTIVITY_SCHEMA = 'http://activitystrea.ms/schema/1.0/';
|
||||
const MEDIA = 'http://purl.org/syndication/atommedia';
|
||||
const SALMON_ME = 'http://salmon-protocol.org/ns/magic-env';
|
||||
const OSTATUSSUB = 'http://ostatus.org/schema/1.0/subscribe';
|
||||
const GEORSS = 'http://www.georss.org/georss';
|
||||
const POCO = 'http://portablecontacts.net/spec/1.0';
|
||||
const FEED = 'http://schemas.google.com/g/2010#updates-from';
|
||||
const OSTATUS = 'http://ostatus.org/schema/1.0';
|
||||
const STATUSNET = 'http://status.net/schema/api/1/';
|
||||
const ATOM1 = 'http://www.w3.org/2005/Atom';
|
||||
const MASTODON = 'http://mastodon.social/schema/1.0';
|
||||
}
|
|
@ -18,6 +18,7 @@ use Friendica\Model\Event;
|
|||
use Friendica\Model\Term;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\JsonLD;
|
||||
|
@ -167,15 +168,15 @@ class Processor
|
|||
public static function createItem($activity)
|
||||
{
|
||||
$item = [];
|
||||
$item['verb'] = ACTIVITY_POST;
|
||||
$item['verb'] = Activity::POST;
|
||||
$item['thr-parent'] = $activity['reply-to-id'];
|
||||
|
||||
if ($activity['reply-to-id'] == $activity['id']) {
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
$item['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
$item['object-type'] = Activity::OBJ_NOTE;
|
||||
} else {
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
$item['object-type'] = ACTIVITY_OBJ_COMMENT;
|
||||
$item['object-type'] = Activity::OBJ_COMMENT;
|
||||
}
|
||||
|
||||
if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
|
||||
|
@ -254,7 +255,7 @@ class Processor
|
|||
$item['verb'] = $verb;
|
||||
$item['thr-parent'] = $activity['object_id'];
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
$item['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
$item['object-type'] = Activity::OBJ_NOTE;
|
||||
|
||||
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Model\APContact;
|
|||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
|
@ -400,26 +401,26 @@ class Receiver
|
|||
$announce_object_data['object_id'] = $object_data['object_id'];
|
||||
$announce_object_data['object_type'] = $object_data['object_type'];
|
||||
|
||||
ActivityPub\Processor::createActivity($announce_object_data, ACTIVITY2_ANNOUNCE);
|
||||
ActivityPub\Processor::createActivity($announce_object_data, Activity::ANNOUNCE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'as:Like':
|
||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_LIKE);
|
||||
ActivityPub\Processor::createActivity($object_data, Activity::LIKE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'as:Dislike':
|
||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_DISLIKE);
|
||||
ActivityPub\Processor::createActivity($object_data, Activity::DISLIKE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'as:TentativeAccept':
|
||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_ATTENDMAYBE);
|
||||
ActivityPub\Processor::createActivity($object_data, Activity::ATTENDMAYBE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -444,7 +445,7 @@ class Receiver
|
|||
ActivityPub\Processor::followUser($object_data);
|
||||
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
$object_data['reply-to-id'] = $object_data['object_id'];
|
||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_FOLLOW);
|
||||
ActivityPub\Processor::createActivity($object_data, Activity::FOLLOW);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -452,7 +453,7 @@ class Receiver
|
|||
if ($object_data['object_type'] == 'as:Follow') {
|
||||
ActivityPub\Processor::acceptFollowUser($object_data);
|
||||
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_ATTEND);
|
||||
ActivityPub\Processor::createActivity($object_data, Activity::ATTEND);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -460,7 +461,7 @@ class Receiver
|
|||
if ($object_data['object_type'] == 'as:Follow') {
|
||||
ActivityPub\Processor::rejectFollowUser($object_data);
|
||||
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_ATTENDNO);
|
||||
ActivityPub\Processor::createActivity($object_data, Activity::ATTENDNO);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\HTTPSignature;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Conversation;
|
||||
|
@ -761,25 +762,25 @@ class Transmitter
|
|||
|
||||
if ($reshared) {
|
||||
$type = 'Announce';
|
||||
} elseif ($item['verb'] == ACTIVITY_POST) {
|
||||
} elseif ($item['verb'] == Activity::POST) {
|
||||
if ($item['created'] == $item['edited']) {
|
||||
$type = 'Create';
|
||||
} else {
|
||||
$type = 'Update';
|
||||
}
|
||||
} elseif ($item['verb'] == ACTIVITY_LIKE) {
|
||||
} elseif ($item['verb'] == Activity::LIKE) {
|
||||
$type = 'Like';
|
||||
} elseif ($item['verb'] == ACTIVITY_DISLIKE) {
|
||||
} elseif ($item['verb'] == Activity::DISLIKE) {
|
||||
$type = 'Dislike';
|
||||
} elseif ($item['verb'] == ACTIVITY_ATTEND) {
|
||||
} elseif ($item['verb'] == Activity::ATTEND) {
|
||||
$type = 'Accept';
|
||||
} elseif ($item['verb'] == ACTIVITY_ATTENDNO) {
|
||||
} elseif ($item['verb'] == Activity::ATTENDNO) {
|
||||
$type = 'Reject';
|
||||
} elseif ($item['verb'] == ACTIVITY_ATTENDMAYBE) {
|
||||
} elseif ($item['verb'] == Activity::ATTENDMAYBE) {
|
||||
$type = 'TentativeAccept';
|
||||
} elseif ($item['verb'] == ACTIVITY_FOLLOW) {
|
||||
} elseif ($item['verb'] == Activity::FOLLOW) {
|
||||
$type = 'Follow';
|
||||
} elseif ($item['verb'] == ACTIVITY_TAG) {
|
||||
} elseif ($item['verb'] == Activity::TAG) {
|
||||
$type = 'Add';
|
||||
} else {
|
||||
$type = '';
|
||||
|
@ -1571,7 +1572,7 @@ class Transmitter
|
|||
$uid = $first_user['uid'];
|
||||
}
|
||||
|
||||
$condition = ['verb' => ACTIVITY_FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||
$condition = ['verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||
'author-id' => Contact::getPublicIdByUserId($uid)];
|
||||
if (Item::exists($condition)) {
|
||||
Logger::log('Follow for ' . $object . ' for user ' . $uid . ' does already exist.', Logger::DEBUG);
|
||||
|
|
|
@ -34,6 +34,7 @@ use Friendica\Model\Profile;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\Activity\Namespaces;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -382,18 +383,18 @@ class DFRN
|
|||
$type = 'html';
|
||||
|
||||
if ($conversation) {
|
||||
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
|
||||
$root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
|
||||
$doc->appendChild($root);
|
||||
|
||||
$root->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
||||
$root->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
||||
$root->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
||||
$root->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
||||
$root->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
||||
$root->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||
$root->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||
$root->setAttribute("xmlns:at", Namespaces::TOMB);
|
||||
$root->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||
$root->setAttribute("xmlns:dfrn", Namespaces::DFRN);
|
||||
$root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||
$root->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||
$root->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||
$root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||
|
||||
//$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
|
||||
|
||||
|
@ -557,18 +558,18 @@ class DFRN
|
|||
$alternatelink = $owner['url'];
|
||||
}
|
||||
|
||||
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
|
||||
$root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
|
||||
$doc->appendChild($root);
|
||||
|
||||
$root->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
||||
$root->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
||||
$root->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
||||
$root->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
||||
$root->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
||||
$root->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||
$root->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||
$root->setAttribute("xmlns:at", Namespaces::TOMB);
|
||||
$root->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||
$root->setAttribute("xmlns:dfrn", Namespaces::DFRN);
|
||||
$root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||
$root->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||
$root->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||
$root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||
|
||||
XML::addElement($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
|
||||
XML::addElement($doc, $root, "title", $owner["name"]);
|
||||
|
@ -941,18 +942,18 @@ class DFRN
|
|||
if (!$single) {
|
||||
$entry = $doc->createElement("entry");
|
||||
} else {
|
||||
$entry = $doc->createElementNS(NAMESPACE_ATOM1, 'entry');
|
||||
$entry = $doc->createElementNS(Namespaces::ATOM1, 'entry');
|
||||
$doc->appendChild($entry);
|
||||
|
||||
$entry->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
||||
$entry->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
||||
$entry->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
||||
$entry->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
||||
$entry->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
||||
$entry->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
||||
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||
$entry->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||
$entry->setAttribute("xmlns:at", Namespaces::TOMB);
|
||||
$entry->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||
$entry->setAttribute("xmlns:dfrn", Namespaces::DFRN);
|
||||
$entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||
$entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||
$entry->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||
$entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||
$entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||
}
|
||||
|
||||
if ($item['private']) {
|
||||
|
@ -1079,9 +1080,9 @@ class DFRN
|
|||
if ($item['object-type'] != "") {
|
||||
XML::addElement($doc, $entry, "activity:object-type", $item['object-type']);
|
||||
} elseif ($item['id'] == $item['parent']) {
|
||||
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
|
||||
XML::addElement($doc, $entry, "activity:object-type", Activity::OBJ_NOTE);
|
||||
} else {
|
||||
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_COMMENT);
|
||||
XML::addElement($doc, $entry, "activity:object-type", Activity::OBJ_COMMENT);
|
||||
}
|
||||
|
||||
$actobj = self::createActivity($doc, "activity:object", $item['object']);
|
||||
|
@ -1124,7 +1125,7 @@ class DFRN
|
|||
"link",
|
||||
"",
|
||||
["rel" => "mentioned",
|
||||
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
|
||||
"ostatus:object-type" => Activity::OBJ_GROUP,
|
||||
"href" => $mention]
|
||||
);
|
||||
} else {
|
||||
|
@ -1134,7 +1135,7 @@ class DFRN
|
|||
"link",
|
||||
"",
|
||||
["rel" => "mentioned",
|
||||
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
|
||||
"ostatus:object-type" => Activity::OBJ_PERSON,
|
||||
"href" => $mention]
|
||||
);
|
||||
}
|
||||
|
@ -1750,7 +1751,7 @@ class DFRN
|
|||
$obj_doc = new DOMDocument("1.0", "utf-8");
|
||||
$obj_doc->formatOutput = true;
|
||||
|
||||
$obj_element = $obj_doc->createElementNS(NAMESPACE_ATOM1, $element);
|
||||
$obj_element = $obj_doc->createElementNS( Namespaces::ATOM1, $element);
|
||||
|
||||
$activity_type = $xpath->query("activity:object-type/text()", $activity)->item(0)->nodeValue;
|
||||
XML::addElement($obj_doc, $obj_element, "type", $activity_type);
|
||||
|
@ -1907,7 +1908,7 @@ class DFRN
|
|||
'source_name' => $importer['name'],
|
||||
'source_link' => $importer['url'],
|
||||
'source_photo' => $importer['photo'],
|
||||
'verb' => ACTIVITY_REQ_FRIEND,
|
||||
'verb' => Activity::REQ_FRIEND,
|
||||
'otype' => 'intro']
|
||||
);
|
||||
|
||||
|
@ -2117,7 +2118,7 @@ class DFRN
|
|||
}
|
||||
$xo = XML::parseString($item["object"], false);
|
||||
|
||||
if (($xo->type == ACTIVITY_OBJ_PERSON) && ($xo->id)) {
|
||||
if (($xo->type == Activity::OBJ_PERSON) && ($xo->id)) {
|
||||
// somebody was poked/prodded. Was it me?
|
||||
$Blink = '';
|
||||
foreach ($xo->link as $l) {
|
||||
|
@ -2186,32 +2187,32 @@ class DFRN
|
|||
|
||||
// Big question: Do we need these functions? They were part of the "consume_feed" function.
|
||||
// This function once was responsible for DFRN and OStatus.
|
||||
if ($activity->match($item["verb"], ACTIVITY_FOLLOW)) {
|
||||
if ($activity->match($item["verb"], Activity::FOLLOW)) {
|
||||
Logger::log("New follower");
|
||||
Contact::addRelationship($importer, $contact, $item);
|
||||
return false;
|
||||
}
|
||||
if ($activity->match($item["verb"], ACTIVITY_UNFOLLOW)) {
|
||||
if ($activity->match($item["verb"], Activity::UNFOLLOW)) {
|
||||
Logger::log("Lost follower");
|
||||
Contact::removeFollower($importer, $contact, $item);
|
||||
return false;
|
||||
}
|
||||
if ($activity->match($item["verb"], ACTIVITY_REQ_FRIEND)) {
|
||||
if ($activity->match($item["verb"], Activity::REQ_FRIEND)) {
|
||||
Logger::log("New friend request");
|
||||
Contact::addRelationship($importer, $contact, $item, true);
|
||||
return false;
|
||||
}
|
||||
if ($activity->match($item["verb"], ACTIVITY_UNFRIEND)) {
|
||||
if ($activity->match($item["verb"], Activity::UNFRIEND)) {
|
||||
Logger::log("Lost sharer");
|
||||
Contact::removeSharer($importer, $contact, $item);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (($item["verb"] == ACTIVITY_LIKE)
|
||||
|| ($item["verb"] == ACTIVITY_DISLIKE)
|
||||
|| ($item["verb"] == ACTIVITY_ATTEND)
|
||||
|| ($item["verb"] == ACTIVITY_ATTENDNO)
|
||||
|| ($item["verb"] == ACTIVITY_ATTENDMAYBE)
|
||||
if (($item["verb"] == Activity::LIKE)
|
||||
|| ($item["verb"] == Activity::DISLIKE)
|
||||
|| ($item["verb"] == Activity::ATTEND)
|
||||
|| ($item["verb"] == Activity::ATTENDNO)
|
||||
|| ($item["verb"] == Activity::ATTENDMAYBE)
|
||||
) {
|
||||
$is_like = true;
|
||||
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||
|
@ -2238,11 +2239,11 @@ class DFRN
|
|||
$is_like = false;
|
||||
}
|
||||
|
||||
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
|
||||
if (($item["verb"] == Activity::TAG) && ($item["object-type"] == Activity::OBJ_TAGTERM)) {
|
||||
$xo = XML::parseString($item["object"], false);
|
||||
$xt = XML::parseString($item["target"], false);
|
||||
|
||||
if ($xt->type == ACTIVITY_OBJ_NOTE) {
|
||||
if ($xt->type == Activity::OBJ_NOTE) {
|
||||
$item_tag = Item::selectFirst(['id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
|
||||
|
||||
if (!DBA::isResult($item_tag)) {
|
||||
|
@ -2517,7 +2518,7 @@ class DFRN
|
|||
// Now assign the rest of the values that depend on the type of the message
|
||||
if (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) {
|
||||
if (!isset($item["object-type"])) {
|
||||
$item["object-type"] = ACTIVITY_OBJ_COMMENT;
|
||||
$item["object-type"] = Activity::OBJ_COMMENT;
|
||||
}
|
||||
|
||||
if ($item["contact-id"] != $owner["contact-id"]) {
|
||||
|
@ -2541,11 +2542,11 @@ class DFRN
|
|||
$item["wall"] = 1;
|
||||
} elseif ($entrytype == DFRN::TOP_LEVEL) {
|
||||
if (!isset($item["object-type"])) {
|
||||
$item["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||
$item["object-type"] = Activity::OBJ_NOTE;
|
||||
}
|
||||
|
||||
// Is it an event?
|
||||
if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) {
|
||||
if (($item["object-type"] == Activity::OBJ_EVENT) && !$owner_unknown) {
|
||||
Logger::log("Item ".$item["uri"]." seems to contain an event.", Logger::DEBUG);
|
||||
$ev = Event::fromBBCode($item["body"]);
|
||||
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
|
||||
|
@ -2642,7 +2643,7 @@ class DFRN
|
|||
Item::distribute($posted_id);
|
||||
}
|
||||
|
||||
if (stristr($item["verb"], ACTIVITY_POKE)) {
|
||||
if (stristr($item["verb"], Activity::POKE)) {
|
||||
$item['id'] = $posted_id;
|
||||
self::doPoke($item, $importer);
|
||||
}
|
||||
|
@ -2731,16 +2732,16 @@ class DFRN
|
|||
@$doc->loadXML($xml);
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath->registerNamespace("atom", NAMESPACE_ATOM1);
|
||||
$xpath->registerNamespace("thr", NAMESPACE_THREAD);
|
||||
$xpath->registerNamespace("at", NAMESPACE_TOMB);
|
||||
$xpath->registerNamespace("media", NAMESPACE_MEDIA);
|
||||
$xpath->registerNamespace("dfrn", NAMESPACE_DFRN);
|
||||
$xpath->registerNamespace("activity", NAMESPACE_ACTIVITY);
|
||||
$xpath->registerNamespace("georss", NAMESPACE_GEORSS);
|
||||
$xpath->registerNamespace("poco", NAMESPACE_POCO);
|
||||
$xpath->registerNamespace("ostatus", NAMESPACE_OSTATUS);
|
||||
$xpath->registerNamespace("statusnet", NAMESPACE_STATUSNET);
|
||||
$xpath->registerNamespace("atom", Namespaces::ATOM1);
|
||||
$xpath->registerNamespace("thr", Namespaces::THREAD);
|
||||
$xpath->registerNamespace("at", Namespaces::TOMB);
|
||||
$xpath->registerNamespace("media", Namespaces::MEDIA);
|
||||
$xpath->registerNamespace("dfrn", Namespaces::DFRN);
|
||||
$xpath->registerNamespace("activity", Namespaces::ACTIVITY);
|
||||
$xpath->registerNamespace("georss", Namespaces::GEORSS);
|
||||
$xpath->registerNamespace("poco", Namespaces::POCO);
|
||||
$xpath->registerNamespace("ostatus", Namespaces::OSTATUS);
|
||||
$xpath->registerNamespace("statusnet", Namespaces::STATUSNET);
|
||||
|
||||
$header = [];
|
||||
$header["uid"] = $importer["importer_uid"];
|
||||
|
@ -2865,7 +2866,7 @@ class DFRN
|
|||
if ($item['verb']) {
|
||||
return $item['verb'];
|
||||
}
|
||||
return ACTIVITY_POST;
|
||||
return Activity::POST;
|
||||
}
|
||||
|
||||
private static function tgroupCheck($uid, $item)
|
||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Model\Mail;
|
|||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Activity\Namespaces;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
|
@ -465,7 +466,7 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
$base = $basedom->children(NAMESPACE_SALMON_ME);
|
||||
$base = $basedom->children(Namespaces::SALMON_ME);
|
||||
|
||||
// Not sure if this cleaning is needed
|
||||
$data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data);
|
||||
|
@ -577,7 +578,7 @@ class Diaspora
|
|||
$author_link = str_replace('acct:', '', $idom->author_id);
|
||||
}
|
||||
|
||||
$dom = $basedom->children(NAMESPACE_SALMON_ME);
|
||||
$dom = $basedom->children(Namespaces::SALMON_ME);
|
||||
|
||||
// figure out where in the DOM tree our data is hiding
|
||||
|
||||
|
@ -1845,7 +1846,7 @@ class Diaspora
|
|||
$datarray["guid"] = $guid;
|
||||
$datarray["uri"] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray["verb"] = ACTIVITY_POST;
|
||||
$datarray["verb"] = Activity::POST;
|
||||
$datarray["gravity"] = GRAVITY_COMMENT;
|
||||
|
||||
if ($thr_uri != "") {
|
||||
|
@ -1854,7 +1855,7 @@ class Diaspora
|
|||
$datarray["parent-uri"] = $parent_item["uri"];
|
||||
}
|
||||
|
||||
$datarray["object-type"] = ACTIVITY_OBJ_COMMENT;
|
||||
$datarray["object-type"] = Activity::OBJ_COMMENT;
|
||||
|
||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray["source"] = $xml;
|
||||
|
@ -2062,9 +2063,9 @@ class Diaspora
|
|||
// "positive" = "false" would be a Dislike - wich isn't currently supported by Diaspora
|
||||
// We would accept this anyhow.
|
||||
if ($positive == "true") {
|
||||
$verb = ACTIVITY_LIKE;
|
||||
$verb = Activity::LIKE;
|
||||
} else {
|
||||
$verb = ACTIVITY_DISLIKE;
|
||||
$verb = Activity::DISLIKE;
|
||||
}
|
||||
|
||||
$datarray = [];
|
||||
|
@ -2085,7 +2086,7 @@ class Diaspora
|
|||
$datarray["gravity"] = GRAVITY_ACTIVITY;
|
||||
$datarray["parent-uri"] = $parent_item["uri"];
|
||||
|
||||
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||
$datarray["object-type"] = Activity::OBJ_NOTE;
|
||||
|
||||
$datarray["body"] = $verb;
|
||||
|
||||
|
@ -2684,9 +2685,9 @@ class Diaspora
|
|||
$datarray['uri'] = self::getUriFromGuid($author, $datarray['guid']);
|
||||
$datarray['parent-uri'] = $parent['uri'];
|
||||
|
||||
$datarray['verb'] = $datarray['body'] = ACTIVITY2_ANNOUNCE;
|
||||
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
|
||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||
$datarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||
$datarray['object-type'] = Activity::OBJ_NOTE;
|
||||
|
||||
$datarray['protocol'] = $item['protocol'];
|
||||
|
||||
|
@ -2757,7 +2758,7 @@ class Diaspora
|
|||
$datarray["guid"] = $guid;
|
||||
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray["verb"] = ACTIVITY_POST;
|
||||
$datarray["verb"] = Activity::POST;
|
||||
$datarray["gravity"] = GRAVITY_PARENT;
|
||||
|
||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||
|
@ -2962,9 +2963,9 @@ class Diaspora
|
|||
XML::unescape($photo->remote_photo_name)."[/img]\n".$body;
|
||||
}
|
||||
|
||||
$datarray["object-type"] = ACTIVITY_OBJ_IMAGE;
|
||||
$datarray["object-type"] = Activity::OBJ_IMAGE;
|
||||
} else {
|
||||
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||
$datarray["object-type"] = Activity::OBJ_NOTE;
|
||||
|
||||
// Add OEmbed and other information to the body
|
||||
if (!self::isRedmatrix($contact["url"])) {
|
||||
|
@ -2994,7 +2995,7 @@ class Diaspora
|
|||
$datarray["guid"] = $guid;
|
||||
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
|
||||
|
||||
$datarray["verb"] = ACTIVITY_POST;
|
||||
$datarray["verb"] = Activity::POST;
|
||||
$datarray["gravity"] = GRAVITY_PARENT;
|
||||
|
||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||
|
@ -3780,9 +3781,9 @@ class Diaspora
|
|||
|
||||
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
|
||||
$positive = null;
|
||||
if ($item['verb'] === ACTIVITY_LIKE) {
|
||||
if ($item['verb'] === Activity::LIKE) {
|
||||
$positive = "true";
|
||||
} elseif ($item['verb'] === ACTIVITY_DISLIKE) {
|
||||
} elseif ($item['verb'] === Activity::DISLIKE) {
|
||||
$positive = "false";
|
||||
}
|
||||
|
||||
|
@ -3811,13 +3812,13 @@ class Diaspora
|
|||
}
|
||||
|
||||
switch ($item['verb']) {
|
||||
case ACTIVITY_ATTEND:
|
||||
case Activity::ATTEND:
|
||||
$attend_answer = 'accepted';
|
||||
break;
|
||||
case ACTIVITY_ATTENDNO:
|
||||
case Activity::ATTENDNO:
|
||||
$attend_answer = 'declined';
|
||||
break;
|
||||
case ACTIVITY_ATTENDMAYBE:
|
||||
case Activity::ATTENDMAYBE:
|
||||
$attend_answer = 'tentative';
|
||||
break;
|
||||
default:
|
||||
|
@ -3913,13 +3914,13 @@ class Diaspora
|
|||
*/
|
||||
public static function sendFollowup(array $item, array $owner, array $contact, $public_batch = false)
|
||||
{
|
||||
if (in_array($item['verb'], [ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE])) {
|
||||
if (in_array($item['verb'], [Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE])) {
|
||||
$message = self::constructAttend($item, $owner);
|
||||
$type = "event_participation";
|
||||
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
||||
} elseif (in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$message = self::constructLike($item, $owner);
|
||||
$type = "like";
|
||||
} elseif (!in_array($item["verb"], [ACTIVITY_FOLLOW, ACTIVITY_TAG])) {
|
||||
} elseif (!in_array($item["verb"], [Activity::FOLLOW, Activity::TAG])) {
|
||||
$message = self::constructComment($item, $owner);
|
||||
$type = "comment";
|
||||
}
|
||||
|
@ -3948,7 +3949,7 @@ class Diaspora
|
|||
$message = ["author" => $item['signer'],
|
||||
"target_guid" => $signed_parts[0],
|
||||
"target_type" => $signed_parts[1]];
|
||||
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
||||
} elseif (in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$message = ["author" => $signed_parts[4],
|
||||
"guid" => $signed_parts[1],
|
||||
"parent_guid" => $signed_parts[3],
|
||||
|
@ -3993,7 +3994,7 @@ class Diaspora
|
|||
{
|
||||
if ($item["deleted"]) {
|
||||
return self::sendRetraction($item, $owner, $contact, $public_batch, true);
|
||||
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
||||
} elseif (in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$type = "like";
|
||||
} else {
|
||||
$type = "comment";
|
||||
|
@ -4054,7 +4055,7 @@ class Diaspora
|
|||
|
||||
if ($item['id'] == $item['parent']) {
|
||||
$target_type = "Post";
|
||||
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
||||
} elseif (in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$target_type = "Like";
|
||||
} else {
|
||||
$target_type = "Comment";
|
||||
|
@ -4320,7 +4321,7 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
||||
if (!in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Protocol\Activity\Namespaces;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -59,13 +60,13 @@ class Feed {
|
|||
$doc = new DOMDocument();
|
||||
@$doc->loadXML(trim($xml));
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
||||
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||
$xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/");
|
||||
$xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/");
|
||||
$xpath->registerNamespace('rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
||||
$xpath->registerNamespace('rss', "http://purl.org/rss/1.0/");
|
||||
$xpath->registerNamespace('media', "http://search.yahoo.com/mrss/");
|
||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
||||
$xpath->registerNamespace('poco', Namespaces::POCO);
|
||||
|
||||
$author = [];
|
||||
$entries = null;
|
||||
|
@ -198,8 +199,8 @@ class Feed {
|
|||
$header["origin"] = 0;
|
||||
$header["gravity"] = GRAVITY_PARENT;
|
||||
$header["private"] = 2;
|
||||
$header["verb"] = ACTIVITY_POST;
|
||||
$header["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||
$header["verb"] = Activity::POST;
|
||||
$header["object-type"] = Activity::OBJ_NOTE;
|
||||
|
||||
$header["contact-id"] = $contact["id"];
|
||||
|
||||
|
@ -420,7 +421,7 @@ class Feed {
|
|||
$item["title"] = "";
|
||||
$item["body"] = $item["body"].add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
||||
$item["tag"] = add_page_keywords($item["plink"], $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
||||
$item["object-type"] = ACTIVITY_OBJ_BOOKMARK;
|
||||
$item["object-type"] = Activity::OBJ_BOOKMARK;
|
||||
unset($item["attach"]);
|
||||
} else {
|
||||
if (!empty($summary)) {
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\User;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\Activity\Namespaces;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
|
@ -261,14 +262,14 @@ class OStatus
|
|||
@$doc->loadXML($xml);
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
||||
$xpath->registerNamespace('thr', NAMESPACE_THREAD);
|
||||
$xpath->registerNamespace('georss', NAMESPACE_GEORSS);
|
||||
$xpath->registerNamespace('activity', NAMESPACE_ACTIVITY);
|
||||
$xpath->registerNamespace('media', NAMESPACE_MEDIA);
|
||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
||||
$xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
|
||||
$xpath->registerNamespace('statusnet', NAMESPACE_STATUSNET);
|
||||
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||
$xpath->registerNamespace('thr', Namespaces::THREAD);
|
||||
$xpath->registerNamespace('georss', Namespaces::GEORSS);
|
||||
$xpath->registerNamespace('activity', Namespaces::ACTIVITY);
|
||||
$xpath->registerNamespace('media', Namespaces::MEDIA);
|
||||
$xpath->registerNamespace('poco', Namespaces::POCO);
|
||||
$xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
|
||||
$xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
|
||||
|
||||
$contact = ["id" => 0];
|
||||
|
||||
|
@ -342,14 +343,14 @@ class OStatus
|
|||
@$doc->loadXML($xml);
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
||||
$xpath->registerNamespace('thr', NAMESPACE_THREAD);
|
||||
$xpath->registerNamespace('georss', NAMESPACE_GEORSS);
|
||||
$xpath->registerNamespace('activity', NAMESPACE_ACTIVITY);
|
||||
$xpath->registerNamespace('media', NAMESPACE_MEDIA);
|
||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
||||
$xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
|
||||
$xpath->registerNamespace('statusnet', NAMESPACE_STATUSNET);
|
||||
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||
$xpath->registerNamespace('thr', Namespaces::THREAD);
|
||||
$xpath->registerNamespace('georss', Namespaces::GEORSS);
|
||||
$xpath->registerNamespace('activity', Namespaces::ACTIVITY);
|
||||
$xpath->registerNamespace('media', Namespaces::MEDIA);
|
||||
$xpath->registerNamespace('poco', Namespaces::POCO);
|
||||
$xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
|
||||
$xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
|
||||
|
||||
$hub = "";
|
||||
$hub_items = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0);
|
||||
|
@ -428,12 +429,12 @@ class OStatus
|
|||
$item["verb"] = XML::getFirstNodeValue($xpath, 'activity:verb/text()', $entry);
|
||||
|
||||
// Delete a message
|
||||
if (in_array($item["verb"], ['qvitter-delete-notice', ACTIVITY_DELETE, 'delete'])) {
|
||||
if (in_array($item["verb"], ['qvitter-delete-notice', Activity::DELETE, 'delete'])) {
|
||||
self::deleteNotice($item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($item["verb"], [NAMESPACE_OSTATUS."/unfavorite", ACTIVITY_UNFAVORITE])) {
|
||||
if (in_array($item["verb"], [Namespaces::OSTATUS . "/unfavorite", Activity::UNFAVORITE])) {
|
||||
// Ignore "Unfavorite" message
|
||||
Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG);
|
||||
continue;
|
||||
|
@ -447,7 +448,7 @@ class OStatus
|
|||
Logger::log('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', Logger::DEBUG);
|
||||
}
|
||||
|
||||
if ($item["verb"] == ACTIVITY_JOIN) {
|
||||
if ($item["verb"] == Activity::JOIN) {
|
||||
// ignore "Join" messages
|
||||
Logger::log("Ignore join message ".print_r($item, true), Logger::DEBUG);
|
||||
continue;
|
||||
|
@ -459,29 +460,29 @@ class OStatus
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($item["verb"] == ACTIVITY_FOLLOW) {
|
||||
if ($item["verb"] == Activity::FOLLOW) {
|
||||
Contact::addRelationship($importer, $contact, $item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item["verb"] == NAMESPACE_OSTATUS."/unfollow") {
|
||||
if ($item["verb"] == Namespaces::OSTATUS."/unfollow") {
|
||||
$dummy = null;
|
||||
Contact::removeFollower($importer, $contact, $item, $dummy);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item["verb"] == ACTIVITY_FAVORITE) {
|
||||
if ($item["verb"] == Activity::FAVORITE) {
|
||||
$orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue;
|
||||
Logger::log("Favorite ".$orig_uri." ".print_r($item, true));
|
||||
|
||||
$item["verb"] = ACTIVITY_LIKE;
|
||||
$item["verb"] = Activity::LIKE;
|
||||
$item["parent-uri"] = $orig_uri;
|
||||
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||
$item["object-type"] = ACTIVITY_OBJ_NOTE;
|
||||
$item["object-type"] = Activity::OBJ_NOTE;
|
||||
}
|
||||
|
||||
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
||||
if (!in_array($item["verb"], [ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE])) {
|
||||
if (!in_array($item["verb"], [Activity::POST, Activity::LIKE, Activity::SHARE])) {
|
||||
Logger::log("Unhandled verb ".$item["verb"]." ".print_r($item, true), Logger::DEBUG);
|
||||
}
|
||||
|
||||
|
@ -504,7 +505,7 @@ class OStatus
|
|||
if ($valid) {
|
||||
// Never post a thread when the only interaction by our contact was a like
|
||||
$valid = false;
|
||||
$verbs = [ACTIVITY_POST, ACTIVITY_SHARE];
|
||||
$verbs = [Activity::POST, Activity::SHARE];
|
||||
foreach (self::$itemlist as $item) {
|
||||
if (in_array($item['verb'], $verbs) && Contact::isSharingByURL($item['author-link'], $item['uid'])) {
|
||||
$valid = true;
|
||||
|
@ -592,10 +593,10 @@ class OStatus
|
|||
{
|
||||
$item["body"] = HTML::toBBCode(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
|
||||
$item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $entry);
|
||||
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) || ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
|
||||
if (($item["object-type"] == Activity::OBJ_BOOKMARK) || ($item["object-type"] == Activity::OBJ_EVENT)) {
|
||||
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
|
||||
$item["body"] = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
|
||||
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
|
||||
} elseif ($item["object-type"] == Activity::OBJ_QUESTION) {
|
||||
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
|
||||
}
|
||||
|
||||
|
@ -676,7 +677,7 @@ class OStatus
|
|||
}
|
||||
}
|
||||
// Is it a repeated post?
|
||||
if (($repeat_of != "") || ($item["verb"] == ACTIVITY_SHARE)) {
|
||||
if (($repeat_of != "") || ($item["verb"] == Activity::SHARE)) {
|
||||
$link_data = self::processRepeatedItem($xpath, $entry, $item, $importer);
|
||||
if (!empty($link_data['add_body'])) {
|
||||
$add_body .= $link_data['add_body'];
|
||||
|
@ -691,7 +692,7 @@ class OStatus
|
|||
}
|
||||
|
||||
// Mastodon Content Warning
|
||||
if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
|
||||
if (($item["verb"] == Activity::POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
|
||||
$clear_text = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
|
||||
if (!empty($clear_text)) {
|
||||
$item['content-warning'] = HTML::toBBCode($clear_text);
|
||||
|
@ -803,9 +804,9 @@ class OStatus
|
|||
@$doc->loadXML($xml);
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
||||
$xpath->registerNamespace('thr', NAMESPACE_THREAD);
|
||||
$xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
|
||||
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||
$xpath->registerNamespace('thr', Namespaces::THREAD);
|
||||
$xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
|
||||
|
||||
$entries = $xpath->query('/atom:feed/atom:entry');
|
||||
|
||||
|
@ -1067,7 +1068,7 @@ class OStatus
|
|||
$item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $activityobject);
|
||||
|
||||
// Mastodon Content Warning
|
||||
if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $activityobject)) {
|
||||
if (($item["verb"] == Activity::POST) && $xpath->evaluate('boolean(atom:summary)', $activityobject)) {
|
||||
$clear_text = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $activityobject);
|
||||
if (!empty($clear_text)) {
|
||||
$item['content-warning'] = HTML::toBBCode($clear_text);
|
||||
|
@ -1105,8 +1106,8 @@ class OStatus
|
|||
switch ($attribute['rel']) {
|
||||
case "alternate":
|
||||
$item["plink"] = $attribute['href'];
|
||||
if (($item["object-type"] == ACTIVITY_OBJ_QUESTION)
|
||||
|| ($item["object-type"] == ACTIVITY_OBJ_EVENT)
|
||||
if (($item["object-type"] == Activity::OBJ_QUESTION)
|
||||
|| ($item["object-type"] == Activity::OBJ_EVENT)
|
||||
) {
|
||||
$item["body"] .= add_page_info($attribute['href']);
|
||||
}
|
||||
|
@ -1135,7 +1136,7 @@ class OStatus
|
|||
}
|
||||
break;
|
||||
case "related":
|
||||
if ($item["object-type"] != ACTIVITY_OBJ_BOOKMARK) {
|
||||
if ($item["object-type"] != Activity::OBJ_BOOKMARK) {
|
||||
if (!isset($item["parent-uri"])) {
|
||||
$item["parent-uri"] = $attribute['href'];
|
||||
}
|
||||
|
@ -1281,17 +1282,17 @@ class OStatus
|
|||
*/
|
||||
private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
|
||||
{
|
||||
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
|
||||
$root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
|
||||
$doc->appendChild($root);
|
||||
|
||||
$root->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
||||
$root->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
||||
$root->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
||||
$root->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
||||
$root->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||
$root->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||
$root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||
$root->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||
$root->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||
$root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||
$root->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
|
||||
|
||||
$title = '';
|
||||
$selfUri = '/feed/' . $owner["nick"] . '/';
|
||||
|
@ -1461,9 +1462,9 @@ class OStatus
|
|||
$author = $doc->createElement("author");
|
||||
XML::addElement($doc, $author, "id", $owner["url"]);
|
||||
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_GROUP);
|
||||
XML::addElement($doc, $author, "activity:object-type", Activity::OBJ_GROUP);
|
||||
} else {
|
||||
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||
XML::addElement($doc, $author, "activity:object-type", Activity::OBJ_PERSON);
|
||||
}
|
||||
XML::addElement($doc, $author, "uri", $owner["url"]);
|
||||
XML::addElement($doc, $author, "name", $owner["nick"]);
|
||||
|
@ -1544,7 +1545,7 @@ class OStatus
|
|||
return $item['verb'];
|
||||
}
|
||||
|
||||
return ACTIVITY_POST;
|
||||
return Activity::POST;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1556,11 +1557,11 @@ class OStatus
|
|||
*/
|
||||
private static function constructObjecttype(array $item)
|
||||
{
|
||||
if (!empty($item['object-type']) && in_array($item['object-type'], [ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT])) {
|
||||
if (!empty($item['object-type']) && in_array($item['object-type'], [Activity::OBJ_NOTE, Activity::OBJ_COMMENT])) {
|
||||
return $item['object-type'];
|
||||
}
|
||||
|
||||
return ACTIVITY_OBJ_NOTE;
|
||||
return Activity::OBJ_NOTE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1589,9 +1590,9 @@ class OStatus
|
|||
return $xml;
|
||||
}
|
||||
|
||||
if ($item["verb"] == ACTIVITY_LIKE) {
|
||||
if ($item["verb"] == Activity::LIKE) {
|
||||
return self::likeEntry($doc, $item, $owner, $toplevel);
|
||||
} elseif (in_array($item["verb"], [ACTIVITY_FOLLOW, NAMESPACE_OSTATUS."/unfollow"])) {
|
||||
} elseif (in_array($item["verb"], [Activity::FOLLOW, Namespaces::OSTATUS . "/unfollow"])) {
|
||||
return self::followEntry($doc, $item, $owner, $toplevel);
|
||||
} else {
|
||||
return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
|
||||
|
@ -1705,11 +1706,11 @@ class OStatus
|
|||
|
||||
$title = $owner["nick"]." repeated a notice by ".$contact["nick"];
|
||||
|
||||
self::entryContent($doc, $entry, $item, $owner, $title, ACTIVITY_SHARE, false);
|
||||
self::entryContent($doc, $entry, $item, $owner, $title, Activity::SHARE, false);
|
||||
|
||||
$as_object = $doc->createElement("activity:object");
|
||||
|
||||
XML::addElement($doc, $as_object, "activity:object-type", NAMESPACE_ACTIVITY_SCHEMA."activity");
|
||||
XML::addElement($doc, $as_object, "activity:object-type", Namespaces::ACTIVITY_SCHEMA . "activity");
|
||||
|
||||
self::entryContent($doc, $as_object, $repeated_item, $owner, "", "", false);
|
||||
|
||||
|
@ -1759,7 +1760,7 @@ class OStatus
|
|||
|
||||
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
|
||||
|
||||
$verb = NAMESPACE_ACTIVITY_SCHEMA."favorite";
|
||||
$verb = Activity\Namespaces::ACTIVITY_SCHEMA."favorite";
|
||||
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
|
||||
|
||||
$parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);
|
||||
|
@ -1790,7 +1791,7 @@ class OStatus
|
|||
private static function addPersonObject(DOMDocument $doc, array $owner, array $contact)
|
||||
{
|
||||
$object = $doc->createElement("activity:object");
|
||||
XML::addElement($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||
XML::addElement($doc, $object, "activity:object-type", Activity::OBJ_PERSON);
|
||||
|
||||
if ($contact['network'] == Protocol::PHANTOM) {
|
||||
XML::addElement($doc, $object, "id", $contact['url']);
|
||||
|
@ -1858,7 +1859,7 @@ class OStatus
|
|||
$connect_id = 0;
|
||||
}
|
||||
|
||||
if ($item['verb'] == ACTIVITY_FOLLOW) {
|
||||
if ($item['verb'] == Activity::FOLLOW) {
|
||||
$message = L10n::t('%s is now following %s.');
|
||||
$title = L10n::t('following');
|
||||
$action = "subscription";
|
||||
|
@ -1918,7 +1919,7 @@ class OStatus
|
|||
|
||||
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
|
||||
|
||||
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
|
||||
XML::addElement($doc, $entry, "activity:object-type", Activity::OBJ_NOTE);
|
||||
|
||||
self::entryContent($doc, $entry, $item, $owner, $title, '', true, $feed_mode);
|
||||
|
||||
|
@ -1950,16 +1951,16 @@ class OStatus
|
|||
$entry->appendChild($author);
|
||||
}
|
||||
} else {
|
||||
$entry = $doc->createElementNS(NAMESPACE_ATOM1, "entry");
|
||||
$entry = $doc->createElementNS(Namespaces::ATOM1, "entry");
|
||||
|
||||
$entry->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
||||
$entry->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
||||
$entry->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
||||
$entry->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
||||
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||
$entry->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
||||
$entry->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||
$entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||
$entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||
$entry->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||
$entry->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||
$entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||
$entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||
$entry->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
|
||||
|
||||
$author = self::addAuthor($doc, $owner);
|
||||
$entry->appendChild($author);
|
||||
|
@ -2111,14 +2112,14 @@ class OStatus
|
|||
XML::addElement($doc, $entry, "link", "",
|
||||
[
|
||||
"rel" => "mentioned",
|
||||
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
|
||||
"ostatus:object-type" => Activity::OBJ_GROUP,
|
||||
"href" => $mention]
|
||||
);
|
||||
} else {
|
||||
XML::addElement($doc, $entry, "link", "",
|
||||
[
|
||||
"rel" => "mentioned",
|
||||
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
|
||||
"ostatus:object-type" => Activity::OBJ_PERSON,
|
||||
"href" => $mention]
|
||||
);
|
||||
}
|
||||
|
@ -2231,7 +2232,7 @@ class OStatus
|
|||
|
||||
if ($filter === 'comments') {
|
||||
$condition[0] .= " AND `object-type` = ? ";
|
||||
$condition[] = ACTIVITY_OBJ_COMMENT;
|
||||
$condition[] = Activity::OBJ_COMMENT;
|
||||
}
|
||||
|
||||
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue