use Friendica\Object\Post;
use Friendica\Object\Thread;
use Friendica\Protocol\Activity;
+use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
-use Friendica\Util\Temporal;
use Friendica\Util\Strings;
+use Friendica\Util\Temporal;
use Friendica\Util\XML;
-use Friendica\Util\Crypto;
function item_extract_images($body) {
switch ($obj['verb']) {
case Activity::POST:
switch ($obj['object-type']) {
- case Activity::OBJ_EVENT:
+ case Activity\ObjectType::EVENT:
$post_type = L10n::t('event');
break;
default:
if ($activity->match($item['verb'], Activity::FRIEND)) {
- if ($item['object-type']=="" || $item['object-type']!== Activity::OBJ_PERSON) return;
+ if ($item['object-type']=="" || $item['object-type']!== Activity\ObjectType::PERSON) return;
$Aname = $item['author-name'];
$Alink = $item['author-link'];
if (!$verb) {
return;
}
- if ($item['object-type']=="" || $item['object-type']!== Activity::OBJ_PERSON) {
+ if ($item['object-type']=="" || $item['object-type']!== Activity\ObjectType::PERSON) {
return;
}
switch ($obj['verb']) {
case Activity::POST:
switch ($obj['object-type']) {
- case Activity::OBJ_EVENT:
+ case Activity\ObjectType::EVENT:
$post_type = L10n::t('event');
break;
default:
// @TODO below if() block can be rewritten to a single line: $isVisible = allConditionsHere;
if ($activity->match($item['verb'], Activity::FOLLOW) &&
- $item['object-type'] === Activity::OBJ_NOTE &&
+ $item['object-type'] === Activity\ObjectType::NOTE &&
empty($item['self']) &&
$item['uid'] == local_user()) {
return false;
$toplevel_item_id = $toplevel_item['id'];
$parent_user = $toplevel_item['uid'];
- $objecttype = Activity::OBJ_COMMENT;
+ $objecttype = Activity\ObjectType::COMMENT;
}
if ($toplevel_item_id) {
$match = null;
if (!$preview && Photo::setPermissionFromBody($body, $profile_uid, $original_contact_id, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny)) {
- $objecttype = Activity::OBJ_IMAGE;
+ $objecttype = Activity\ObjectType::IMAGE;
}
/*
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
- $objecttype = Activity::OBJ_BOOKMARK;
+ $objecttype = Activity\ObjectType::BOOKMARK;
}
/** @var BBCode\Video $bbCodeVideo */
// Setting the object type if not defined before
if (!$objecttype) {
- $objecttype = Activity::OBJ_NOTE; // Default value
+ $objecttype = Activity\ObjectType::NOTE; // Default value
$objectdata = BBCode::getAttachedData($body);
if ($objectdata["type"] == "link") {
- $objecttype = Activity::OBJ_BOOKMARK;
+ $objecttype = Activity\ObjectType::BOOKMARK;
} elseif ($objectdata["type"] == "video") {
- $objecttype = Activity::OBJ_VIDEO;
+ $objecttype = Activity\ObjectType::VIDEO;
} elseif ($objectdata["type"] == "photo") {
- $objecttype = Activity::OBJ_IMAGE;
+ $objecttype = Activity\ObjectType::IMAGE;
}
}
$arr['visible'] = 1;
$arr['verb'] = Activity::TAG;
$arr['gravity'] = GRAVITY_PARENT;
- $arr['object-type'] = Activity::OBJ_PERSON;
- $arr['target-type'] = Activity::OBJ_IMAGE;
+ $arr['object-type'] = Activity\ObjectType::PERSON;
+ $arr['target-type'] = Activity\ObjectType::IMAGE;
$arr['tag'] = $tagged[4];
$arr['inform'] = $tagged[2];
$arr['origin'] = 1;
$arr['body'] = L10n::t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . L10n::t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
$arr['body'] .= "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . System::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
- $arr['object'] = '<object><type>' . Activity::OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
+ $arr['object'] = '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
if ($tagged[3]) {
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
}
$arr['object'] .= '</link></object>' . "\n";
- $arr['target'] = '<target><type>' . Activity::OBJ_IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
+ $arr['target'] = '<target><type>' . Activity\ObjectType::IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
. System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id>';
$arr['target'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . System::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
$arr['visible'] = 1;
$arr['verb'] = $activity;
$arr['private'] = $private;
- $arr['object-type'] = Activity::OBJ_PERSON;
+ $arr['object-type'] = Activity\ObjectType::PERSON;
$arr['origin'] = 1;
$arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . L10n::t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
- $arr['object'] = '<object><type>' . Activity::OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $target['url'] . '</id>';
+ $arr['object'] = '<object><type>' . Activity\ObjectType::PERSON . '</type><title>' . $target['name'] . '</title><id>' . $target['url'] . '</id>';
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
$arr['object'] .= XML::escape('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
/**
* @file mod/subthread.php
*/
+
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
$uri = Item::newURI($owner_uid);
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
- $objtype = (($item['resource-id']) ? Activity::OBJ_IMAGE : Activity::OBJ_NOTE );
+ $objtype = (($item['resource-id']) ? Activity\ObjectType::IMAGE : Activity\ObjectType::NOTE );
$link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $item['guid'] . '" />' . "\n");
$body = $item['body'];
/**
* @file mod/tagger.php
*/
+
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
-use Friendica\Core\System;
use Friendica\Core\Session;
+use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Item;
$uri = Item::newURI($owner_uid);
$xterm = XML::escape($term);
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
- $targettype = (($item['resource-id']) ? Activity::OBJ_IMAGE : Activity::OBJ_NOTE );
+ $targettype = (($item['resource-id']) ? Activity\ObjectType::IMAGE : Activity\ObjectType::NOTE );
$href = System::baseUrl() . '/display/' . $item['guid'];
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");
EOT;
$tagid = System::baseUrl() . '/search?tag=' . $xterm;
- $objtype = Activity::OBJ_TAGTERM;
+ $objtype = Activity\ObjectType::TAGTERM;
$obj = <<< EOT
<object>
if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
if ((count($pictures) == 1) && !$has_title) {
- if (!empty($item['object-type']) && ($item['object-type'] == Activity::OBJ_IMAGE)) {
+ if (!empty($item['object-type']) && ($item['object-type'] == Activity\ObjectType::IMAGE)) {
// Replace the preview picture with the real picture
$url = str_replace('-1.', '-0.', $pictures[0][2]);
$data = ['url' => $url, 'type' => 'photo'];
} elseif (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
// create an unfollow slap
$item = [];
- $item['verb'] = Activity\ANamespace::OSTATUS . "/unfollow";
+ $item['verb'] = Activity::O_UNFOLLOW;
$item['follow'] = $contact["url"];
$item['body'] = '';
$item['title'] = '';
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBA::isResult($item)) {
- $object = '<object><type>' . XML::escape(Activity::OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
+ $object = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
$object .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
$object .= '</object>' . "\n";
$item_arr['private'] = $private;
$item_arr['visible'] = 1;
$item_arr['verb'] = Activity::POST;
- $item_arr['object-type'] = Activity::OBJ_EVENT;
+ $item_arr['object-type'] = Activity\ObjectType::EVENT;
$item_arr['origin'] = $event['cid'] === 0 ? 1 : 0;
$item_arr['body'] = self::getBBCode($event);
$item_arr['event-id'] = $event['id'];
- $item_arr['object'] = '<object><type>' . XML::escape(Activity::OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
+ $item_arr['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
$item_arr['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
$item_arr['object'] .= '</object>' . "\n";
$row['object'] = '';
}
if (array_key_exists('object-type', $row)) {
- $row['object-type'] = Activity::OBJ_NOTE;
+ $row['object-type'] = Activity\ObjectType::NOTE;
}
} elseif (array_key_exists('verb', $row) && in_array($row['verb'], ['', Activity::POST, Activity::SHARE])) {
// Posts don't have an object or target - but having tags or files.
private static function deleteTagsFromItem($item)
{
- if (($item["verb"] != Activity::TAG) || ($item["object-type"] != Activity::OBJ_TAGTERM)) {
+ if (($item["verb"] != Activity::TAG) || ($item["object-type"] != Activity\ObjectType::TAGTERM)) {
return;
}
$xo = XML::parseString($item["object"], false);
$xt = XML::parseString($item["target"], false);
- if ($xt->type != Activity::OBJ_NOTE) {
+ if ($xt->type != Activity\ObjectType::NOTE) {
return;
}
return true;
}
- $objtype = $item['resource-id'] ? Activity::OBJ_IMAGE : Activity::OBJ_NOTE;
+ $objtype = $item['resource-id'] ? Activity\ObjectType::IMAGE : Activity\ObjectType::NOTE;
$new_item = [
'guid' => System::createUUID(),
// In order to provide theme developers more possibilities, event items
// are treated differently.
- if ($item['object-type'] === Activity::OBJ_EVENT && isset($item['event-id'])) {
+ if ($item['object-type'] === Activity\ObjectType::EVENT && isset($item['event-id'])) {
$ev = Event::getItemHTML($item);
return $ev;
}
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item;
$isevent = false;
$attend = [];
- if ($item['object-type'] === Activity::OBJ_EVENT) {
+ if ($item['object-type'] === Activity\ObjectType::EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
use Friendica\Protocol\Activity\ANamespace;
/**
- * Base class for the Activity constants and particular method
+ * Base class for the Activity Verbs
*/
final class Activity
{
- const LIKE = ANamespace::ACTIVITY_SCHEMA . 'like';
+ /**
+ * Indicates that the actor marked the object as an item of special interest.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const LIKE = ANamespace::ACTIVITY_SCHEMA . 'like';
+ /**
+ * Dislike a message ("I don't like the post")
+ *
+ * @see http://purl.org/macgirvin/dfrn/1.0/dislike
+ * @var string
+ */
+ const DISLIKE = ANamespace::DFRN . '/dislike';
- const DISLIKE = ANamespace::DFRN . '/dislike';
- const ATTEND = ANamespace::ZOT . '/activity/attendyes';
- const ATTENDNO = ANamespace::ZOT . '/activity/attendno';
- const ATTENDMAYBE = ANamespace::ZOT . '/activity/attendmaybe';
- const OBJ_HEART = ANamespace::DFRN . '/heart';
+ /**
+ * Attend an event
+ *
+ * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attend
+ * @var string
+ */
+ const ATTEND = ANamespace::ZOT . '/activity/attendyes';
+ /**
+ * Don't attend an event
+ *
+ * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendno
+ * @var string
+ */
+ const ATTENDNO = ANamespace::ZOT . '/activity/attendno';
+ /**
+ * Attend maybe an event
+ *
+ * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_attendmaybe
+ * @var string
+ */
+ const ATTENDMAYBE = ANamespace::ZOT . '/activity/attendmaybe';
- const FRIEND = ANamespace::ACTIVITY_SCHEMA . 'make-friend';
- const REQ_FRIEND = ANamespace::ACTIVITY_SCHEMA . 'request-friend';
- const UNFRIEND = ANamespace::ACTIVITY_SCHEMA . 'remove-friend';
- const FOLLOW = ANamespace::ACTIVITY_SCHEMA . 'follow';
- const UNFOLLOW = ANamespace::ACTIVITY_SCHEMA . 'stop-following';
- const JOIN = ANamespace::ACTIVITY_SCHEMA . 'join';
- const POST = ANamespace::ACTIVITY_SCHEMA . 'post';
- const UPDATE = ANamespace::ACTIVITY_SCHEMA . 'update';
- const TAG = ANamespace::ACTIVITY_SCHEMA . 'tag';
- const FAVORITE = ANamespace::ACTIVITY_SCHEMA . 'favorite';
- const UNFAVORITE = ANamespace::ACTIVITY_SCHEMA . 'unfavorite';
- const SHARE = ANamespace::ACTIVITY_SCHEMA . 'share';
- const DELETE = ANamespace::ACTIVITY_SCHEMA . 'delete';
- const ANNOUNCE = ANamespace::ACTIVITY2 . 'Announce';
+ /**
+ * Indicates the creation of a friendship that is reciprocated by the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const FRIEND = ANamespace::ACTIVITY_SCHEMA . 'make-friend';
+ /**
+ * Indicates the creation of a friendship that has not yet been reciprocated by the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const REQ_FRIEND = ANamespace::ACTIVITY_SCHEMA . 'request-friend';
+ /**
+ * Indicates that the actor has removed the object from the collection of friends.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const UNFRIEND = ANamespace::ACTIVITY_SCHEMA . 'remove-friend';
+ /**
+ * Indicates that the actor began following the activity of the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const FOLLOW = ANamespace::ACTIVITY_SCHEMA . 'follow';
+ /**
+ * Indicates that the actor has stopped following the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const UNFOLLOW = ANamespace::ACTIVITY_SCHEMA . 'stop-following';
+ /**
+ * Indicates that the actor has become a member of the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const JOIN = ANamespace::ACTIVITY_SCHEMA . 'join';
+ /**
+ * Implementors SHOULD use verbs such as post where the actor is adding new items to a collection or similar.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const POST = ANamespace::ACTIVITY_SCHEMA . 'post';
+ /**
+ * The "update" verb indicates that the actor has modified the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const UPDATE = ANamespace::ACTIVITY_SCHEMA . 'update';
+ /**
+ * Indicates that the actor has identified the presence of a target inside another object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const TAG = ANamespace::ACTIVITY_SCHEMA . 'tag';
+ /**
+ * Indicates that the actor marked the object as an item of special interest.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const FAVORITE = ANamespace::ACTIVITY_SCHEMA . 'favorite';
+ /**
+ * Indicates that the actor has removed the object from the collection of favorited items.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const UNFAVORITE = ANamespace::ACTIVITY_SCHEMA . 'unfavorite';
+ /**
+ * Indicates that the actor has called out the object to readers.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const SHARE = ANamespace::ACTIVITY_SCHEMA . 'share';
+ /**
+ * Indicates that the actor has deleted the object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#verbs
+ * @var string
+ */
+ const DELETE = ANamespace::ACTIVITY_SCHEMA . 'delete';
+ /**
+ * Indicates that the actor is calling the target's attention the object.
+ *
+ * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
+ * @var string
+ */
+ const ANNOUNCE = ANamespace::ACTIVITY2 . 'Announce';
- const POKE = ANamespace::ZOT . '/activity/poke';
+ /**
+ * Pokes an user.
+ *
+ * @see https://github.com/friendica/friendica/wiki/ActivityStreams#activity_poke
+ * @var string
+ */
+ const POKE = ANamespace::ZOT . '/activity/poke';
- const OBJ_BOOKMARK = ANamespace::ACTIVITY_SCHEMA . 'bookmark';
- const OBJ_COMMENT = ANamespace::ACTIVITY_SCHEMA . 'comment';
- const OBJ_NOTE = ANamespace::ACTIVITY_SCHEMA . 'note';
- const OBJ_PERSON = ANamespace::ACTIVITY_SCHEMA . 'person';
- const OBJ_IMAGE = ANamespace::ACTIVITY_SCHEMA . 'image';
- const OBJ_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'photo';
- const OBJ_VIDEO = ANamespace::ACTIVITY_SCHEMA . 'video';
- const OBJ_P_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'profile-photo';
- const OBJ_ALBUM = ANamespace::ACTIVITY_SCHEMA . 'photo-album';
- const OBJ_EVENT = ANamespace::ACTIVITY_SCHEMA . 'event';
- const OBJ_GROUP = ANamespace::ACTIVITY_SCHEMA . 'group';
- const OBJ_TAGTERM = ANamespace::DFRN . '/tagterm';
- const OBJ_PROFILE = ANamespace::DFRN . '/profile';
- const OBJ_QUESTION = 'http://activityschema.org/object/question';
+ const O_UNFOLLOW = ANamespace::OSTATUS . '/unfollow';
+ const O_UNFAVOURITE = ANamespace::OSTATUS . '/unfavorite';
/**
* likes (etc.) can apply to other things besides posts. Check if they are post children,
*/
final class ANamespace
{
+ /**
+ * Zot is a WebMTA which provides a decentralised identity and communications protocol using HTTPS/JSON.
+ *
+ * @var string
+ * @see https://zotlabs.org/page/zotlabs/specs+zot6+home
+ */
const ZOT = 'http://purl.org/zot';
+ /**
+ * Friendica is using ActivityStreams in version 1.0 for its activities and object types.
+ * Additional types are used for non standard activities.
+ *
+ * @var string
+ * @see https://github.com/friendica/friendica/wiki/ActivityStreams
+ */
const DFRN = 'http://purl.org/macgirvin/dfrn/1.0';
+ /**
+ * This namespace defines an extension for expressing threaded
+ * discussions within the Atom Syndication Format [RFC4287]
+ *
+ * @see https://tools.ietf.org/rfc/rfc4685.txt
+ * @var string
+ */
const THREAD = 'http://purl.org/syndication/thread/1.0';
+ /**
+ * This namespace adds mechanisms to the Atom Syndication Format
+ * that publishers of Atom Feed and Entry documents can use to
+ * explicitly identify Atom entries that have been removed.
+ *
+ * @see https://tools.ietf.org/html/rfc6721
+ * @var string
+ */
const TOMB = 'http://purl.org/atompub/tombstones/1.0';
+ /**
+ * This specification details a model for representing potential and completed activities
+ * using the JSON format.
+ *
+ * @see https://www.w3.org/ns/activitystreams
+ * @var string
+ */
const ACTIVITY2 = 'https://www.w3.org/ns/activitystreams#';
+ /**
+ * Atom Activities 1.0
+ *
+ * This namespace presents an XML format that allows activities on social objects
+ * to be expressed within the Atom Syndication Format.
+ *
+ * @see http://activitystrea.ms/spec/1.0
+ * @var string
+ */
const ACTIVITY = 'http://activitystrea.ms/spec/1.0/';
+ /**
+ * This namespace presents a base set of Object types and Verbs for use with Activity Streams.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html
+ * @var string
+ */
const ACTIVITY_SCHEMA = 'http://activitystrea.ms/schema/1.0/';
+ /**
+ * Atom Media Extensions
+ *
+ * @var string
+ */
const MEDIA = 'http://purl.org/syndication/atommedia';
+ /**
+ * The Salmon Protocol is an open, simple, standards-based solution that lets
+ * aggregators and sources unify the conversations.
+ *
+ * @see http://www.salmon-protocol.org/salmon-protocol-summary
+ * @var string
+ */
const SALMON_ME = 'http://salmon-protocol.org/ns/magic-env';
+ /**
+ * OStatus is a minimal specification for distributed status updates or microblogging.
+ *
+ * @see https://ostatus.github.io/spec/OStatus%201.0%20Draft%202.html
+ * @var string
+ */
const OSTATUSSUB = 'http://ostatus.org/schema/1.0/subscribe';
+ /**
+ * GeoRSS was designed as a lightweight, community driven way to extend existing feeds with geographic information.
+ *
+ * @see http://www.georss.org/
+ * @var string
+ */
const GEORSS = 'http://www.georss.org/georss';
+ /**
+ * The Portable Contacts specification is designed to make it easier for developers
+ * to give their users a secure way to access the address books and friends lists
+ * they have built up all over the web.
+ *
+ * @see http://portablecontacts.net/draft-spec/
+ * @var string
+ */
const POCO = 'http://portablecontacts.net/spec/1.0';
+ /**
+ * @var string
+ */
const FEED = 'http://schemas.google.com/g/2010#updates-from';
+ /**
+ * OStatus is a minimal specification for distributed status updates or microblogging.
+ *
+ * @see https://ostatus.github.io/spec/OStatus%201.0%20Draft%202.html
+ * @var string
+ */
const OSTATUS = 'http://ostatus.org/schema/1.0';
+ /**
+ * @var string
+ */
const STATUSNET = 'http://status.net/schema/api/1/';
+ /**
+ * This namespace describes the Atom Activity Streams in RDF Vocabulary (AAIR),
+ * defined as a dictionary of named properties and classes using W3C's RDF technology,
+ * and specifically a mapping of the Atom Activity Streams work to RDF.
+ *
+ * @see http://xmlns.notu.be/aair/#RFC4287
+ * @var string
+ */
const ATOM1 = 'http://www.w3.org/2005/Atom';
+ /**
+ * @var string
+ */
const MASTODON = 'http://mastodon.social/schema/1.0';
}
--- /dev/null
+<?php
+
+namespace Friendica\Protocol\Activity;
+
+/**
+ * This class contains the different object types in activities
+ */
+final class ObjectType
+{
+ /**
+ * The "bookmark" object type represents a pointer to some URL -- typically a web page.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#bookmark
+ * @var string
+ */
+ const BOOKMARK = ANamespace::ACTIVITY_SCHEMA . 'bookmark';
+ /**
+ * The "comment" object type represents a textual response to another object.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#comment
+ * @var string
+ */
+ const COMMENT = ANamespace::ACTIVITY_SCHEMA . 'comment';
+ /**
+ * The "comment" object type represents a textual response to another object.
+ * (Default type for items)
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#note
+ * @var string
+ */
+ const NOTE = ANamespace::ACTIVITY_SCHEMA . 'note';
+ /**
+ * The "person" object type represents a user account.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#person
+ * @var string
+ */
+ const PERSON = ANamespace::ACTIVITY_SCHEMA . 'person';
+ /**
+ * The "image" object type represents a graphical image.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#image
+ * @var string
+ */
+ const IMAGE = ANamespace::ACTIVITY_SCHEMA . 'image';
+ /**
+ * @var string
+ */
+ const PHOTO = ANamespace::ACTIVITY_SCHEMA . 'photo';
+ /**
+ * The "video" object type represents video content,
+ * which usually consists of a motion picture track and an audio track.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#video
+ * @var string
+ */
+ const VIDEO = ANamespace::ACTIVITY_SCHEMA . 'video';
+ /**
+ * @var string
+ */
+ const PROFILE_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'profile-photo';
+ /**
+ * @var string
+ */
+ const ALBUM = ANamespace::ACTIVITY_SCHEMA . 'photo-album';
+ /**
+ * The "event" object type represents an event that occurs in a certain place during a particular interval of time.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#event
+ * @var string
+ */
+ const EVENT = ANamespace::ACTIVITY_SCHEMA . 'event';
+ /**
+ * The "group" object type represents a grouping of objects in which member objects can join or leave.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#group
+ * @var string
+ */
+ const GROUP = ANamespace::ACTIVITY_SCHEMA . 'group';
+
+
+ /**
+ * @var string
+ */
+ const HEART = ANamespace::DFRN . '/heart';
+ /**
+ * @var string
+ */
+ const TAGTERM = ANamespace::DFRN . '/tagterm';
+ /**
+ * @var string
+ */
+ const PROFILE = ANamespace::DFRN . '/profile';
+
+
+ /**
+ * The "question" object type represents a question or poll.
+ *
+ * @see http://activitystrea.ms/head/activity-schema.html#question
+ * @var string
+ */
+ const QUESTION = 'http://activityschema.org/object/question';
+}
*/
namespace Friendica\Protocol\ActivityPub;
-use Friendica\Database\DBA;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
-use Friendica\Core\PConfig;
use Friendica\Core\Logger;
+use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
-use Friendica\Model\Contact;
+use Friendica\Database\DBA;
use Friendica\Model\APContact;
-use Friendica\Model\Item;
+use Friendica\Model\Contact;
use Friendica\Model\Event;
+use Friendica\Model\Item;
+use Friendica\Model\Mail;
use Friendica\Model\Term;
use Friendica\Model\User;
-use Friendica\Model\Mail;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\DateTimeFormat;
if ($activity['reply-to-id'] == $activity['id']) {
$item['gravity'] = GRAVITY_PARENT;
- $item['object-type'] = Activity::OBJ_NOTE;
+ $item['object-type'] = Activity\ObjectType::NOTE;
} else {
$item['gravity'] = GRAVITY_COMMENT;
- $item['object-type'] = Activity::OBJ_COMMENT;
+ $item['object-type'] = Activity\ObjectType::COMMENT;
}
if (empty($activity['directmessage']) && ($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
$item['verb'] = $verb;
$item['thr-parent'] = $activity['object_id'];
$item['gravity'] = GRAVITY_ACTIVITY;
- $item['object-type'] = Activity::OBJ_NOTE;
+ $item['object-type'] = Activity\ObjectType::NOTE;
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
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\ObjectType::NOTE);
} else {
- XML::addElement($doc, $entry, "activity:object-type", Activity::OBJ_COMMENT);
+ XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::COMMENT);
}
$actobj = self::createActivity($doc, "activity:object", $item['object']);
"link",
"",
["rel" => "mentioned",
- "ostatus:object-type" => Activity::OBJ_GROUP,
+ "ostatus:object-type" => Activity\ObjectType::GROUP,
"href" => $mention]
);
} else {
"link",
"",
["rel" => "mentioned",
- "ostatus:object-type" => Activity::OBJ_PERSON,
+ "ostatus:object-type" => Activity\ObjectType::PERSON,
"href" => $mention]
);
}
}
$xo = XML::parseString($item["object"], false);
- if (($xo->type == Activity::OBJ_PERSON) && ($xo->id)) {
+ if (($xo->type == Activity\ObjectType::PERSON) && ($xo->id)) {
// somebody was poked/prodded. Was it me?
$Blink = '';
foreach ($xo->link as $l) {
$is_like = false;
}
- if (($item["verb"] == Activity::TAG) && ($item["object-type"] == Activity::OBJ_TAGTERM)) {
+ if (($item["verb"] == Activity::TAG) && ($item["object-type"] == Activity\ObjectType::TAGTERM)) {
$xo = XML::parseString($item["object"], false);
$xt = XML::parseString($item["target"], false);
- if ($xt->type == Activity::OBJ_NOTE) {
+ if ($xt->type == Activity\ObjectType::NOTE) {
$item_tag = Item::selectFirst(['id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
if (!DBA::isResult($item_tag)) {
// 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\ObjectType::COMMENT;
}
if ($item["contact-id"] != $owner["contact-id"]) {
$item["wall"] = 1;
} elseif ($entrytype == DFRN::TOP_LEVEL) {
if (!isset($item["object-type"])) {
- $item["object-type"] = Activity::OBJ_NOTE;
+ $item["object-type"] = Activity\ObjectType::NOTE;
}
// Is it an event?
- if (($item["object-type"] == Activity::OBJ_EVENT) && !$owner_unknown) {
+ if (($item["object-type"] == Activity\ObjectType::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'])) {
$datarray["parent-uri"] = $parent_item["uri"];
}
- $datarray["object-type"] = Activity::OBJ_COMMENT;
+ $datarray["object-type"] = Activity\ObjectType::COMMENT;
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
$datarray["source"] = $xml;
$datarray["gravity"] = GRAVITY_ACTIVITY;
$datarray["parent-uri"] = $parent_item["uri"];
- $datarray["object-type"] = Activity::OBJ_NOTE;
+ $datarray["object-type"] = Activity\ObjectType::NOTE;
$datarray["body"] = $verb;
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
$datarray['gravity'] = GRAVITY_ACTIVITY;
- $datarray['object-type'] = Activity::OBJ_NOTE;
+ $datarray['object-type'] = Activity\ObjectType::NOTE;
$datarray['protocol'] = $item['protocol'];
XML::unescape($photo->remote_photo_name)."[/img]\n".$body;
}
- $datarray["object-type"] = Activity::OBJ_IMAGE;
+ $datarray["object-type"] = Activity\ObjectType::IMAGE;
} else {
- $datarray["object-type"] = Activity::OBJ_NOTE;
+ $datarray["object-type"] = Activity\ObjectType::NOTE;
// Add OEmbed and other information to the body
if (!self::isRedmatrix($contact["url"])) {
$header["gravity"] = GRAVITY_PARENT;
$header["private"] = 2;
$header["verb"] = Activity::POST;
- $header["object-type"] = Activity::OBJ_NOTE;
+ $header["object-type"] = Activity\ObjectType::NOTE;
$header["contact-id"] = $contact["id"];
$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\ObjectType::BOOKMARK;
unset($item["attach"]);
} else {
if (!empty($summary)) {
continue;
}
- if (in_array($item["verb"], [ANamespace::OSTATUS . "/unfavorite", Activity::UNFAVORITE])) {
+ if (in_array($item["verb"], [Activity::O_UNFAVOURITE, Activity::UNFAVORITE])) {
// Ignore "Unfavorite" message
Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG);
continue;
continue;
}
- if ($item["verb"] == ANamespace::OSTATUS . "/unfollow") {
+ if ($item["verb"] == Activity::O_UNFOLLOW) {
$dummy = null;
Contact::removeFollower($importer, $contact, $item, $dummy);
continue;
$item["verb"] = Activity::LIKE;
$item["parent-uri"] = $orig_uri;
$item["gravity"] = GRAVITY_ACTIVITY;
- $item["object-type"] = Activity::OBJ_NOTE;
+ $item["object-type"] = Activity\ObjectType::NOTE;
}
// http://activitystrea.ms/schema/1.0/rsvp-yes
{
$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\ObjectType::BOOKMARK) || ($item["object-type"] == Activity\ObjectType::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\ObjectType::QUESTION) {
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
}
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\ObjectType::QUESTION)
+ || ($item["object-type"] == Activity\ObjectType::EVENT)
) {
$item["body"] .= add_page_info($attribute['href']);
}
}
break;
case "related":
- if ($item["object-type"] != Activity::OBJ_BOOKMARK) {
+ if ($item["object-type"] != Activity\ObjectType::BOOKMARK) {
if (!isset($item["parent-uri"])) {
$item["parent-uri"] = $attribute['href'];
}
$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\ObjectType::GROUP);
} else {
- XML::addElement($doc, $author, "activity:object-type", Activity::OBJ_PERSON);
+ XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::PERSON);
}
XML::addElement($doc, $author, "uri", $owner["url"]);
XML::addElement($doc, $author, "name", $owner["nick"]);
*/
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\ObjectType::NOTE, Activity\ObjectType::COMMENT])) {
return $item['object-type'];
}
- return Activity::OBJ_NOTE;
+ return Activity\ObjectType::NOTE;
}
/**
if ($item["verb"] == Activity::LIKE) {
return self::likeEntry($doc, $item, $owner, $toplevel);
- } elseif (in_array($item["verb"], [Activity::FOLLOW, ANamespace::OSTATUS . "/unfollow"])) {
+ } elseif (in_array($item["verb"], [Activity::FOLLOW, Activity::O_UNFOLLOW])) {
return self::followEntry($doc, $item, $owner, $toplevel);
} else {
return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
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\ObjectType::PERSON);
if ($contact['network'] == Protocol::PHANTOM) {
XML::addElement($doc, $object, "id", $contact['url']);
$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\ObjectType::NOTE);
self::entryContent($doc, $entry, $item, $owner, $title, '', true, $feed_mode);
XML::addElement($doc, $entry, "link", "",
[
"rel" => "mentioned",
- "ostatus:object-type" => Activity::OBJ_GROUP,
+ "ostatus:object-type" => Activity\ObjectType::GROUP,
"href" => $mention]
);
} else {
XML::addElement($doc, $entry, "link", "",
[
"rel" => "mentioned",
- "ostatus:object-type" => Activity::OBJ_PERSON,
+ "ostatus:object-type" => Activity\ObjectType::PERSON,
"href" => $mention]
);
}
if ($filter === 'comments') {
$condition[0] .= " AND `object-type` = ? ";
- $condition[] = Activity::OBJ_COMMENT;
+ $condition[] = Activity\ObjectType::COMMENT;
}
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
$datarray = [];
$datarray['verb'] = Activity::POST;
- $datarray['object-type'] = Activity::OBJ_NOTE;
+ $datarray['object-type'] = Activity\ObjectType::NOTE;
$datarray['network'] = Protocol::MAIL;
// $meta = Email::messageMeta($mbox, $msg_uid);
'assert' => true,
],
'simple' => [
- 'haystack' => Activity::OBJ_TAGTERM,
- 'needle' => Activity::OBJ_TAGTERM,
+ 'haystack' => Activity\ObjectType::TAGTERM,
+ 'needle' => Activity\ObjectType::TAGTERM,
'assert' => true,
],
'withNamespace' => [
'haystack' => 'tagterm',
- 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . Activity::OBJ_TAGTERM,
+ 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM,
'assert' => true,
],
'invalidSimple' => [
],
'invalidWithOutNamespace' => [
'haystack' => 'tagterm',
- 'needle' => Activity::OBJ_TAGTERM,
+ 'needle' => Activity\ObjectType::TAGTERM,
'assert' => false,
],
'withSubPath' => [
'haystack' => 'tagterm',
- 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . '/bla/' . Activity::OBJ_TAGTERM,
+ 'needle' => Activity\ANamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM,
'assert' => true,
],
];
$activity = new Activity();
$this->assertTrue($activity->isHidden(Activity::LIKE));
- $this->assertFalse($activity->isHidden(Activity::OBJ_BOOKMARK));
+ $this->assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
}
}