mirror of
https://github.com/friendica/friendica
synced 2024-12-23 03:20:15 +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
73
boot.php
73
boot.php
|
@ -184,79 +184,6 @@ define('TERM_OBJ_POST', Term::OBJECT_TYPE_POST);
|
||||||
/** @deprecated since 2019.03, use Term::OBJECT_TYPE_PHOTO instead */
|
/** @deprecated since 2019.03, use Term::OBJECT_TYPE_PHOTO instead */
|
||||||
define('TERM_OBJ_PHOTO', Term::OBJECT_TYPE_PHOTO);
|
define('TERM_OBJ_PHOTO', Term::OBJECT_TYPE_PHOTO);
|
||||||
|
|
||||||
/**
|
|
||||||
* @name Namespaces
|
|
||||||
*
|
|
||||||
* Various namespaces we may need to parse
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
define('NAMESPACE_ZOT', 'http://purl.org/zot');
|
|
||||||
define('NAMESPACE_DFRN', 'http://purl.org/macgirvin/dfrn/1.0');
|
|
||||||
define('NAMESPACE_THREAD', 'http://purl.org/syndication/thread/1.0');
|
|
||||||
define('NAMESPACE_TOMB', 'http://purl.org/atompub/tombstones/1.0');
|
|
||||||
define('NAMESPACE_ACTIVITY2', 'https://www.w3.org/ns/activitystreams#');
|
|
||||||
define('NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/');
|
|
||||||
define('NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/');
|
|
||||||
define('NAMESPACE_MEDIA', 'http://purl.org/syndication/atommedia');
|
|
||||||
define('NAMESPACE_SALMON_ME', 'http://salmon-protocol.org/ns/magic-env');
|
|
||||||
define('NAMESPACE_OSTATUSSUB', 'http://ostatus.org/schema/1.0/subscribe');
|
|
||||||
define('NAMESPACE_GEORSS', 'http://www.georss.org/georss');
|
|
||||||
define('NAMESPACE_POCO', 'http://portablecontacts.net/spec/1.0');
|
|
||||||
define('NAMESPACE_FEED', 'http://schemas.google.com/g/2010#updates-from');
|
|
||||||
define('NAMESPACE_OSTATUS', 'http://ostatus.org/schema/1.0');
|
|
||||||
define('NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/');
|
|
||||||
define('NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom');
|
|
||||||
define('NAMESPACE_MASTODON', 'http://mastodon.social/schema/1.0');
|
|
||||||
/* @}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @name Activity
|
|
||||||
*
|
|
||||||
* Activity stream defines
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
define('ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like');
|
|
||||||
define('ACTIVITY_DISLIKE', NAMESPACE_DFRN . '/dislike');
|
|
||||||
define('ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes');
|
|
||||||
define('ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno');
|
|
||||||
define('ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe');
|
|
||||||
|
|
||||||
define('ACTIVITY_OBJ_HEART', NAMESPACE_DFRN . '/heart');
|
|
||||||
|
|
||||||
define('ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend');
|
|
||||||
define('ACTIVITY_REQ_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'request-friend');
|
|
||||||
define('ACTIVITY_UNFRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend');
|
|
||||||
define('ACTIVITY_FOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'follow');
|
|
||||||
define('ACTIVITY_UNFOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'stop-following');
|
|
||||||
define('ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join');
|
|
||||||
|
|
||||||
define('ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post');
|
|
||||||
define('ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update');
|
|
||||||
define('ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag');
|
|
||||||
define('ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite');
|
|
||||||
define('ACTIVITY_UNFAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'unfavorite');
|
|
||||||
define('ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share');
|
|
||||||
define('ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete');
|
|
||||||
define('ACTIVITY2_ANNOUNCE', NAMESPACE_ACTIVITY2 . 'Announce');
|
|
||||||
|
|
||||||
define('ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke');
|
|
||||||
|
|
||||||
define('ACTIVITY_OBJ_BOOKMARK', NAMESPACE_ACTIVITY_SCHEMA . 'bookmark');
|
|
||||||
define('ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment');
|
|
||||||
define('ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note');
|
|
||||||
define('ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person');
|
|
||||||
define('ACTIVITY_OBJ_IMAGE', NAMESPACE_ACTIVITY_SCHEMA . 'image');
|
|
||||||
define('ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo');
|
|
||||||
define('ACTIVITY_OBJ_VIDEO', NAMESPACE_ACTIVITY_SCHEMA . 'video');
|
|
||||||
define('ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo');
|
|
||||||
define('ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album');
|
|
||||||
define('ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event');
|
|
||||||
define('ACTIVITY_OBJ_GROUP', NAMESPACE_ACTIVITY_SCHEMA . 'group');
|
|
||||||
define('ACTIVITY_OBJ_TAGTERM', NAMESPACE_DFRN . '/tagterm');
|
|
||||||
define('ACTIVITY_OBJ_PROFILE', NAMESPACE_DFRN . '/profile');
|
|
||||||
define('ACTIVITY_OBJ_QUESTION', 'http://activityschema.org/object/question');
|
|
||||||
/* @}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Gravity
|
* @name Gravity
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,6 +41,7 @@ use Friendica\Network\HTTPException\NotImplementedException;
|
||||||
use Friendica\Network\HTTPException\TooManyRequestsException;
|
use Friendica\Network\HTTPException\TooManyRequestsException;
|
||||||
use Friendica\Network\HTTPException\UnauthorizedException;
|
use Friendica\Network\HTTPException\UnauthorizedException;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
@ -2839,19 +2840,19 @@ function api_format_items_activities($item, $type = "json")
|
||||||
// get user data and add it to the array of the activity
|
// get user data and add it to the array of the activity
|
||||||
$user = api_get_user($a, $parent_item['author-id']);
|
$user = api_get_user($a, $parent_item['author-id']);
|
||||||
switch ($parent_item['verb']) {
|
switch ($parent_item['verb']) {
|
||||||
case ACTIVITY_LIKE:
|
case Activity::LIKE:
|
||||||
$activities['like'][] = $user;
|
$activities['like'][] = $user;
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_DISLIKE:
|
case Activity::DISLIKE:
|
||||||
$activities['dislike'][] = $user;
|
$activities['dislike'][] = $user;
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_ATTEND:
|
case Activity::ATTEND:
|
||||||
$activities['attendyes'][] = $user;
|
$activities['attendyes'][] = $user;
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_ATTENDNO:
|
case Activity::ATTENDNO:
|
||||||
$activities['attendno'][] = $user;
|
$activities['attendno'][] = $user;
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_ATTENDMAYBE:
|
case Activity::ATTENDMAYBE:
|
||||||
$activities['attendmaybe'][] = $user;
|
$activities['attendmaybe'][] = $user;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -5110,7 +5111,7 @@ function api_get_announce($item)
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['author-id', 'author-name', 'author-link', 'author-avatar'];
|
$fields = ['author-id', 'author-name', 'author-link', 'author-avatar'];
|
||||||
$activity = Item::activityToIndex(ACTIVITY2_ANNOUNCE);
|
$activity = Item::activityToIndex(Activity::ANNOUNCE);
|
||||||
$condition = ['parent-uri' => $item['uri'], 'gravity' => GRAVITY_ACTIVITY, 'uid' => [0, $item['uid']], 'activity' => $activity];
|
$condition = ['parent-uri' => $item['uri'], 'gravity' => GRAVITY_ACTIVITY, 'uid' => [0, $item['uid']], 'activity' => $activity];
|
||||||
$announce = Item::selectFirstForUser($item['uid'], $fields, $condition, ['order' => ['received' => true]]);
|
$announce = Item::selectFirstForUser($item['uid'], $fields, $condition, ['order' => ['received' => true]]);
|
||||||
if (!DBA::isResult($announce)) {
|
if (!DBA::isResult($announce)) {
|
||||||
|
|
|
@ -145,11 +145,11 @@ function localize_item(&$item)
|
||||||
$activity = BaseObject::getClass(Activity::class);
|
$activity = BaseObject::getClass(Activity::class);
|
||||||
|
|
||||||
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
|
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
|
||||||
if ($activity->match($item['verb'], ACTIVITY_LIKE)
|
if ($activity->match($item['verb'], Activity::LIKE)
|
||||||
|| $activity->match($item['verb'], ACTIVITY_DISLIKE)
|
|| $activity->match($item['verb'], Activity::DISLIKE)
|
||||||
|| $activity->match($item['verb'], ACTIVITY_ATTEND)
|
|| $activity->match($item['verb'], Activity::ATTEND)
|
||||||
|| $activity->match($item['verb'], ACTIVITY_ATTENDNO)
|
|| $activity->match($item['verb'], Activity::ATTENDNO)
|
||||||
|| $activity->match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
|
|| $activity->match($item['verb'], Activity::ATTENDMAYBE)) {
|
||||||
|
|
||||||
$fields = ['author-link', 'author-name', 'verb', 'object-type', 'resource-id', 'body', 'plink'];
|
$fields = ['author-link', 'author-name', 'verb', 'object-type', 'resource-id', 'body', 'plink'];
|
||||||
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
||||||
|
@ -161,9 +161,9 @@ function localize_item(&$item)
|
||||||
$objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
|
$objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
|
||||||
|
|
||||||
switch ($obj['verb']) {
|
switch ($obj['verb']) {
|
||||||
case ACTIVITY_POST:
|
case Activity::POST:
|
||||||
switch ($obj['object-type']) {
|
switch ($obj['object-type']) {
|
||||||
case ACTIVITY_OBJ_EVENT:
|
case Activity::OBJ_EVENT:
|
||||||
$post_type = L10n::t('event');
|
$post_type = L10n::t('event');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -184,24 +184,24 @@ function localize_item(&$item)
|
||||||
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
|
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
|
||||||
|
|
||||||
$bodyverb = '';
|
$bodyverb = '';
|
||||||
if ($activity->match($item['verb'], ACTIVITY_LIKE)) {
|
if ($activity->match($item['verb'], Activity::LIKE)) {
|
||||||
$bodyverb = L10n::t('%1$s likes %2$s\'s %3$s');
|
$bodyverb = L10n::t('%1$s likes %2$s\'s %3$s');
|
||||||
} elseif ($activity->match($item['verb'], ACTIVITY_DISLIKE)) {
|
} elseif ($activity->match($item['verb'], Activity::DISLIKE)) {
|
||||||
$bodyverb = L10n::t('%1$s doesn\'t like %2$s\'s %3$s');
|
$bodyverb = L10n::t('%1$s doesn\'t like %2$s\'s %3$s');
|
||||||
} elseif ($activity->match($item['verb'], ACTIVITY_ATTEND)) {
|
} elseif ($activity->match($item['verb'], Activity::ATTEND)) {
|
||||||
$bodyverb = L10n::t('%1$s attends %2$s\'s %3$s');
|
$bodyverb = L10n::t('%1$s attends %2$s\'s %3$s');
|
||||||
} elseif ($activity->match($item['verb'], ACTIVITY_ATTENDNO)) {
|
} elseif ($activity->match($item['verb'], Activity::ATTENDNO)) {
|
||||||
$bodyverb = L10n::t('%1$s doesn\'t attend %2$s\'s %3$s');
|
$bodyverb = L10n::t('%1$s doesn\'t attend %2$s\'s %3$s');
|
||||||
} elseif ($activity->match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
|
} elseif ($activity->match($item['verb'], Activity::ATTENDMAYBE)) {
|
||||||
$bodyverb = L10n::t('%1$s attends maybe %2$s\'s %3$s');
|
$bodyverb = L10n::t('%1$s attends maybe %2$s\'s %3$s');
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
|
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activity->match($item['verb'], ACTIVITY_FRIEND)) {
|
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::OBJ_PERSON) return;
|
||||||
|
|
||||||
$Aname = $item['author-name'];
|
$Aname = $item['author-name'];
|
||||||
$Alink = $item['author-link'];
|
$Alink = $item['author-link'];
|
||||||
|
@ -231,12 +231,12 @@ function localize_item(&$item)
|
||||||
$item['body'] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$Bphoto;
|
$item['body'] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$Bphoto;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (stristr($item['verb'], ACTIVITY_POKE)) {
|
if (stristr($item['verb'], Activity::POKE)) {
|
||||||
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
||||||
if (!$verb) {
|
if (!$verb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) {
|
if ($item['object-type']=="" || $item['object-type']!== Activity::OBJ_PERSON) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ function localize_item(&$item)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activity->match($item['verb'], ACTIVITY_TAG)) {
|
if ($activity->match($item['verb'], Activity::TAG)) {
|
||||||
$fields = ['author-id', 'author-link', 'author-name', 'author-network',
|
$fields = ['author-id', 'author-link', 'author-name', 'author-network',
|
||||||
'verb', 'object-type', 'resource-id', 'body', 'plink'];
|
'verb', 'object-type', 'resource-id', 'body', 'plink'];
|
||||||
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
$obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
|
||||||
|
@ -298,9 +298,9 @@ function localize_item(&$item)
|
||||||
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
|
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
|
||||||
|
|
||||||
switch ($obj['verb']) {
|
switch ($obj['verb']) {
|
||||||
case ACTIVITY_POST:
|
case Activity::POST:
|
||||||
switch ($obj['object-type']) {
|
switch ($obj['object-type']) {
|
||||||
case ACTIVITY_OBJ_EVENT:
|
case Activity::OBJ_EVENT:
|
||||||
$post_type = L10n::t('event');
|
$post_type = L10n::t('event');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -326,7 +326,7 @@ function localize_item(&$item)
|
||||||
$item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
|
$item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activity->match($item['verb'], ACTIVITY_FAVORITE)) {
|
if ($activity->match($item['verb'], Activity::FAVORITE)) {
|
||||||
if ($item['object-type'] == "") {
|
if ($item['object-type'] == "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -402,19 +402,15 @@ function visible_activity($item) {
|
||||||
/** @var Activity $activity */
|
/** @var Activity $activity */
|
||||||
$activity = BaseObject::getClass(Activity::class);
|
$activity = BaseObject::getClass(Activity::class);
|
||||||
|
|
||||||
/*
|
if ($activity->isHidden($item['verb'])) {
|
||||||
* likes (etc.) can apply to other things besides posts. Check if they are post children,
|
|
||||||
* in which case we handle them specially
|
|
||||||
*/
|
|
||||||
$hidden_activities = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_FOLLOW, ACTIVITY2_ANNOUNCE];
|
|
||||||
foreach ($hidden_activities as $act) {
|
|
||||||
if ($activity->match($item['verb'], $act)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// @TODO below if() block can be rewritten to a single line: $isVisible = allConditionsHere;
|
// @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 && empty($item['self']) && $item['uid'] == local_user()) {
|
if ($activity->match($item['verb'], Activity::FOLLOW) &&
|
||||||
|
$item['object-type'] === Activity::OBJ_NOTE &&
|
||||||
|
empty($item['self']) &&
|
||||||
|
$item['uid'] == local_user()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +812,7 @@ function conversation_fetch_comments($thread_items) {
|
||||||
$received = '';
|
$received = '';
|
||||||
|
|
||||||
while ($row = Item::fetch($thread_items)) {
|
while ($row = Item::fetch($thread_items)) {
|
||||||
if (($row['verb'] == ACTIVITY2_ANNOUNCE) && !empty($row['contact-uid']) && ($row['received'] > $received) && ($row['thr-parent'] == $row['parent-uri'])) {
|
if (($row['verb'] == Activity::ANNOUNCE) && !empty($row['contact-uid']) && ($row['received'] > $received) && ($row['thr-parent'] == $row['parent-uri'])) {
|
||||||
$actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
|
$actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
|
||||||
$received = $row['received'];
|
$received = $row['received'];
|
||||||
}
|
}
|
||||||
|
@ -1008,22 +1004,22 @@ function builtin_activity_puller($item, &$conv_responses) {
|
||||||
|
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'like':
|
case 'like':
|
||||||
$verb = ACTIVITY_LIKE;
|
$verb = Activity::LIKE;
|
||||||
break;
|
break;
|
||||||
case 'dislike':
|
case 'dislike':
|
||||||
$verb = ACTIVITY_DISLIKE;
|
$verb = Activity::DISLIKE;
|
||||||
break;
|
break;
|
||||||
case 'attendyes':
|
case 'attendyes':
|
||||||
$verb = ACTIVITY_ATTEND;
|
$verb = Activity::ATTEND;
|
||||||
break;
|
break;
|
||||||
case 'attendno':
|
case 'attendno':
|
||||||
$verb = ACTIVITY_ATTENDNO;
|
$verb = Activity::ATTENDNO;
|
||||||
break;
|
break;
|
||||||
case 'attendmaybe':
|
case 'attendmaybe':
|
||||||
$verb = ACTIVITY_ATTENDMAYBE;
|
$verb = Activity::ATTENDMAYBE;
|
||||||
break;
|
break;
|
||||||
case 'announce':
|
case 'announce':
|
||||||
$verb = ACTIVITY2_ANNOUNCE;
|
$verb = Activity::ANNOUNCE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -1386,7 +1382,7 @@ function smart_flatten_conversation(array $parent)
|
||||||
if (isset($child['children']) && count($child['children'])) {
|
if (isset($child['children']) && count($child['children'])) {
|
||||||
// This helps counting only the regular posts
|
// This helps counting only the regular posts
|
||||||
$count_post_closure = function($var) {
|
$count_post_closure = function($var) {
|
||||||
return $var['verb'] === ACTIVITY_POST;
|
return $var['verb'] === Activity::POST;
|
||||||
};
|
};
|
||||||
|
|
||||||
$child_post_count = count(array_filter($child['children'], $count_post_closure));
|
$child_post_count = count(array_filter($child['children'], $count_post_closure));
|
||||||
|
@ -1398,7 +1394,7 @@ function smart_flatten_conversation(array $parent)
|
||||||
|
|
||||||
// Searches the post item in the children
|
// Searches the post item in the children
|
||||||
$j = 0;
|
$j = 0;
|
||||||
while($child['children'][$j]['verb'] !== ACTIVITY_POST && $j < count($child['children'])) {
|
while($child['children'][$j]['verb'] !== Activity::POST && $j < count($child['children'])) {
|
||||||
$j ++;
|
$j ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Emailer;
|
use Friendica\Util\Emailer;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -338,7 +339,7 @@ function notification($params)
|
||||||
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
|
||||||
|
|
||||||
switch ($params['verb']) {
|
switch ($params['verb']) {
|
||||||
case ACTIVITY_FRIEND:
|
case Activity::FRIEND:
|
||||||
// someone started to share with user (mostly OStatus)
|
// someone started to share with user (mostly OStatus)
|
||||||
$subject = L10n::t('[Friendica:Notify] A new person is sharing with you');
|
$subject = L10n::t('[Friendica:Notify] A new person is sharing with you');
|
||||||
|
|
||||||
|
@ -348,7 +349,7 @@ function notification($params)
|
||||||
$sitename
|
$sitename
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_FOLLOW:
|
case Activity::FOLLOW:
|
||||||
// someone started to follow the user (mostly OStatus)
|
// someone started to follow the user (mostly OStatus)
|
||||||
$subject = L10n::t('[Friendica:Notify] You have a new follower');
|
$subject = L10n::t('[Friendica:Notify] You have a new follower');
|
||||||
|
|
||||||
|
@ -385,7 +386,7 @@ function notification($params)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($params['type'] == NOTIFY_CONFIRM) {
|
if ($params['type'] == NOTIFY_CONFIRM) {
|
||||||
if ($params['verb'] == ACTIVITY_FRIEND) { // mutual connection
|
if ($params['verb'] == Activity::FRIEND) { // mutual connection
|
||||||
$itemlink = $params['link'];
|
$itemlink = $params['link'];
|
||||||
$subject = L10n::t('[Friendica:Notify] Connection accepted');
|
$subject = L10n::t('[Friendica:Notify] Connection accepted');
|
||||||
|
|
||||||
|
@ -821,7 +822,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
|
|
||||||
if ($send_notification) {
|
if ($send_notification) {
|
||||||
$params["type"] = NOTIFY_SHARE;
|
$params["type"] = NOTIFY_SHARE;
|
||||||
$params["verb"] = ACTIVITY_TAG;
|
$params["verb"] = Activity::TAG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -835,7 +836,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
|
|
||||||
if ($item["mention"] || $tagged || ($defaulttype == NOTIFY_TAGSELF)) {
|
if ($item["mention"] || $tagged || ($defaulttype == NOTIFY_TAGSELF)) {
|
||||||
$params["type"] = NOTIFY_TAGSELF;
|
$params["type"] = NOTIFY_TAGSELF;
|
||||||
$params["verb"] = ACTIVITY_TAG;
|
$params["verb"] = Activity::TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it a post that the user had started?
|
// Is it a post that the user had started?
|
||||||
|
@ -844,7 +845,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
|
|
||||||
if ($thread['mention'] && !$thread['ignored'] && !isset($params["type"])) {
|
if ($thread['mention'] && !$thread['ignored'] && !isset($params["type"])) {
|
||||||
$params["type"] = NOTIFY_COMMENT;
|
$params["type"] = NOTIFY_COMMENT;
|
||||||
$params["verb"] = ACTIVITY_POST;
|
$params["verb"] = Activity::POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And now we check for participation of one of our contacts in the thread
|
// And now we check for participation of one of our contacts in the thread
|
||||||
|
@ -852,7 +853,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
|
|
||||||
if (!$thread['ignored'] && !isset($params["type"]) && Item::exists($condition)) {
|
if (!$thread['ignored'] && !isset($params["type"]) && Item::exists($condition)) {
|
||||||
$params["type"] = NOTIFY_COMMENT;
|
$params["type"] = NOTIFY_COMMENT;
|
||||||
$params["verb"] = ACTIVITY_POST;
|
$params["verb"] = Activity::POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params["type"])) {
|
if (isset($params["type"])) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\Crypto;
|
use Friendica\Util\Crypto;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
@ -538,7 +539,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
||||||
'source_name' => ((strlen(stripslashes($combined['name']))) ? stripslashes($combined['name']) : L10n::t('[Name Withheld]')),
|
'source_name' => ((strlen(stripslashes($combined['name']))) ? stripslashes($combined['name']) : L10n::t('[Name Withheld]')),
|
||||||
'source_link' => $combined['url'],
|
'source_link' => $combined['url'],
|
||||||
'source_photo' => $combined['photo'],
|
'source_photo' => $combined['photo'],
|
||||||
'verb' => ($mutual?ACTIVITY_FRIEND:ACTIVITY_FOLLOW),
|
'verb' => ($mutual ? Activity::FRIEND : Activity::FOLLOW),
|
||||||
'otype' => 'intro'
|
'otype' => 'intro'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Model\Profile;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Module\Login;
|
use Friendica\Module\Login;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -561,7 +562,7 @@ function dfrn_request_content(App $a)
|
||||||
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : L10n::t('[Name Withheld]')),
|
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : L10n::t('[Name Withheld]')),
|
||||||
'source_link' => $r[0]['url'],
|
'source_link' => $r[0]['url'],
|
||||||
'source_photo' => $r[0]['photo'],
|
'source_photo' => $r[0]['photo'],
|
||||||
'verb' => ACTIVITY_REQ_FRIEND,
|
'verb' => Activity::REQ_FRIEND,
|
||||||
'otype' => 'intro'
|
'otype' => 'intro'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
21
mod/item.php
21
mod/item.php
|
@ -36,6 +36,7 @@ use Friendica\Model\FileTag;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Model\Term;
|
use Friendica\Model\Term;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
use Friendica\Protocol\Email;
|
use Friendica\Protocol\Email;
|
||||||
use Friendica\Util\ACLFormatter;
|
use Friendica\Util\ACLFormatter;
|
||||||
|
@ -133,7 +134,7 @@ function item_post(App $a) {
|
||||||
$toplevel_item_id = $toplevel_item['id'];
|
$toplevel_item_id = $toplevel_item['id'];
|
||||||
$parent_user = $toplevel_item['uid'];
|
$parent_user = $toplevel_item['uid'];
|
||||||
|
|
||||||
$objecttype = ACTIVITY_OBJ_COMMENT;
|
$objecttype = Activity::OBJ_COMMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($toplevel_item_id) {
|
if ($toplevel_item_id) {
|
||||||
|
@ -466,7 +467,7 @@ function item_post(App $a) {
|
||||||
$match = null;
|
$match = null;
|
||||||
|
|
||||||
if (!$preview && Photo::setPermissionFromBody($body, $profile_uid, $original_contact_id, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny)) {
|
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::OBJ_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -502,7 +503,7 @@ function item_post(App $a) {
|
||||||
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
|
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
|
||||||
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
|
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
|
||||||
$posttype = Item::PT_PAGE;
|
$posttype = Item::PT_PAGE;
|
||||||
$objecttype = ACTIVITY_OBJ_BOOKMARK;
|
$objecttype = Activity::OBJ_BOOKMARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var BBCode\Video $bbCodeVideo */
|
/** @var BBCode\Video $bbCodeVideo */
|
||||||
|
@ -516,15 +517,15 @@ function item_post(App $a) {
|
||||||
|
|
||||||
// Setting the object type if not defined before
|
// Setting the object type if not defined before
|
||||||
if (!$objecttype) {
|
if (!$objecttype) {
|
||||||
$objecttype = ACTIVITY_OBJ_NOTE; // Default value
|
$objecttype = Activity::OBJ_NOTE; // Default value
|
||||||
$objectdata = BBCode::getAttachedData($body);
|
$objectdata = BBCode::getAttachedData($body);
|
||||||
|
|
||||||
if ($objectdata["type"] == "link") {
|
if ($objectdata["type"] == "link") {
|
||||||
$objecttype = ACTIVITY_OBJ_BOOKMARK;
|
$objecttype = Activity::OBJ_BOOKMARK;
|
||||||
} elseif ($objectdata["type"] == "video") {
|
} elseif ($objectdata["type"] == "video") {
|
||||||
$objecttype = ACTIVITY_OBJ_VIDEO;
|
$objecttype = Activity::OBJ_VIDEO;
|
||||||
} elseif ($objectdata["type"] == "photo") {
|
} elseif ($objectdata["type"] == "photo") {
|
||||||
$objecttype = ACTIVITY_OBJ_IMAGE;
|
$objecttype = Activity::OBJ_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -549,7 +550,7 @@ function item_post(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen($verb)) {
|
if (!strlen($verb)) {
|
||||||
$verb = ACTIVITY_POST;
|
$verb = Activity::POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($network == "") {
|
if ($network == "") {
|
||||||
|
@ -761,7 +762,7 @@ function item_post(App $a) {
|
||||||
'source_name' => $datarray['author-name'],
|
'source_name' => $datarray['author-name'],
|
||||||
'source_link' => $datarray['author-link'],
|
'source_link' => $datarray['author-link'],
|
||||||
'source_photo' => $datarray['author-avatar'],
|
'source_photo' => $datarray['author-avatar'],
|
||||||
'verb' => ACTIVITY_POST,
|
'verb' => Activity::POST,
|
||||||
'otype' => 'item',
|
'otype' => 'item',
|
||||||
'parent' => $toplevel_item_id,
|
'parent' => $toplevel_item_id,
|
||||||
'parent_uri' => $toplevel_item['uri']
|
'parent_uri' => $toplevel_item['uri']
|
||||||
|
@ -781,7 +782,7 @@ function item_post(App $a) {
|
||||||
'source_name' => $datarray['author-name'],
|
'source_name' => $datarray['author-name'],
|
||||||
'source_link' => $datarray['author-link'],
|
'source_link' => $datarray['author-link'],
|
||||||
'source_photo' => $datarray['author-avatar'],
|
'source_photo' => $datarray['author-avatar'],
|
||||||
'verb' => ACTIVITY_POST,
|
'verb' => Activity::POST,
|
||||||
'otype' => 'item'
|
'otype' => 'item'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Model\Profile;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\ACLFormatter;
|
use Friendica\Util\ACLFormatter;
|
||||||
use Friendica\Util\Crypto;
|
use Friendica\Util\Crypto;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
@ -566,24 +567,24 @@ function photos_post(App $a)
|
||||||
$arr['deny_cid'] = $photo['deny_cid'];
|
$arr['deny_cid'] = $photo['deny_cid'];
|
||||||
$arr['deny_gid'] = $photo['deny_gid'];
|
$arr['deny_gid'] = $photo['deny_gid'];
|
||||||
$arr['visible'] = 1;
|
$arr['visible'] = 1;
|
||||||
$arr['verb'] = ACTIVITY_TAG;
|
$arr['verb'] = Activity::TAG;
|
||||||
$arr['gravity'] = GRAVITY_PARENT;
|
$arr['gravity'] = GRAVITY_PARENT;
|
||||||
$arr['object-type'] = ACTIVITY_OBJ_PERSON;
|
$arr['object-type'] = Activity::OBJ_PERSON;
|
||||||
$arr['target-type'] = ACTIVITY_OBJ_IMAGE;
|
$arr['target-type'] = Activity::OBJ_IMAGE;
|
||||||
$arr['tag'] = $tagged[4];
|
$arr['tag'] = $tagged[4];
|
||||||
$arr['inform'] = $tagged[2];
|
$arr['inform'] = $tagged[2];
|
||||||
$arr['origin'] = 1;
|
$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'] = 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['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::OBJ_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");
|
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
|
||||||
if ($tagged[3]) {
|
if ($tagged[3]) {
|
||||||
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
|
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
|
||||||
}
|
}
|
||||||
$arr['object'] .= '</link></object>' . "\n";
|
$arr['object'] .= '</link></object>' . "\n";
|
||||||
|
|
||||||
$arr['target'] = '<target><type>' . ACTIVITY_OBJ_IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
|
$arr['target'] = '<target><type>' . Activity::OBJ_IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
|
||||||
. System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</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['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>';
|
||||||
|
|
||||||
|
@ -1444,11 +1445,11 @@ function photos_content(App $a)
|
||||||
$template = $tpl;
|
$template = $tpl;
|
||||||
$sparkle = '';
|
$sparkle = '';
|
||||||
|
|
||||||
/** @var \Friendica\Protocol\Activity $activity */
|
/** @var Activity $activity */
|
||||||
$activity = BaseObject::getClass(\Friendica\Protocol\Activity::class);
|
$activity = BaseObject::getClass(Activity::class);
|
||||||
|
|
||||||
if (($activity->match($item['verb'], ACTIVITY_LIKE) ||
|
if (($activity->match($item['verb'], Activity::LIKE) ||
|
||||||
$activity->match($item['verb'], ACTIVITY_DISLIKE)) &&
|
$activity->match($item['verb'], Activity::DISLIKE)) &&
|
||||||
($item['id'] != $item['parent'])) {
|
($item['id'] != $item['parent'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ function poke_init(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
|
$activity = Activity::POKE . '#' . urlencode($verbs[$verb][0]);
|
||||||
|
|
||||||
$contact_id = intval($_GET['cid']);
|
$contact_id = intval($_GET['cid']);
|
||||||
if (!$contact_id) {
|
if (!$contact_id) {
|
||||||
|
@ -117,12 +118,12 @@ function poke_init(App $a)
|
||||||
$arr['visible'] = 1;
|
$arr['visible'] = 1;
|
||||||
$arr['verb'] = $activity;
|
$arr['verb'] = $activity;
|
||||||
$arr['private'] = $private;
|
$arr['private'] = $private;
|
||||||
$arr['object-type'] = ACTIVITY_OBJ_PERSON;
|
$arr['object-type'] = Activity::OBJ_PERSON;
|
||||||
|
|
||||||
$arr['origin'] = 1;
|
$arr['origin'] = 1;
|
||||||
$arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . L10n::t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
|
$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::OBJ_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'] .= '<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");
|
$arr['object'] .= XML::escape('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Protocol\OStatus;
|
use Friendica\Protocol\OStatus;
|
||||||
use Friendica\Protocol\Salmon;
|
use Friendica\Protocol\Salmon;
|
||||||
use Friendica\Util\Crypto;
|
use Friendica\Util\Crypto;
|
||||||
|
@ -36,7 +37,7 @@ function salmon_post(App $a, $xml = '') {
|
||||||
|
|
||||||
// parse the xml
|
// parse the xml
|
||||||
|
|
||||||
$dom = simplexml_load_string($xml,'SimpleXMLElement',0,NAMESPACE_SALMON_ME);
|
$dom = simplexml_load_string($xml,'SimpleXMLElement',0, Namespaces::SALMON_ME);
|
||||||
|
|
||||||
$base = null;
|
$base = null;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\Security;
|
use Friendica\Util\Security;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
@ -20,7 +21,7 @@ function subthread_content(App $a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$activity = ACTIVITY_FOLLOW;
|
$activity = Activity::FOLLOW;
|
||||||
|
|
||||||
$item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0);
|
$item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0);
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ function subthread_content(App $a) {
|
||||||
$uri = Item::newURI($owner_uid);
|
$uri = Item::newURI($owner_uid);
|
||||||
|
|
||||||
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
|
$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::OBJ_IMAGE : Activity::OBJ_NOTE );
|
||||||
$link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $item['guid'] . '" />' . "\n");
|
$link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $item['guid'] . '" />' . "\n");
|
||||||
$body = $item['body'];
|
$body = $item['body'];
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Core\Session;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
use Friendica\Worker\Delivery;
|
use Friendica\Worker\Delivery;
|
||||||
|
@ -68,7 +69,7 @@ function tagger_content(App $a) {
|
||||||
$uri = Item::newURI($owner_uid);
|
$uri = Item::newURI($owner_uid);
|
||||||
$xterm = XML::escape($term);
|
$xterm = XML::escape($term);
|
||||||
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
|
$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::OBJ_IMAGE : Activity::OBJ_NOTE );
|
||||||
$href = System::baseUrl() . '/display/' . $item['guid'];
|
$href = System::baseUrl() . '/display/' . $item['guid'];
|
||||||
|
|
||||||
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");
|
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");
|
||||||
|
@ -87,7 +88,7 @@ function tagger_content(App $a) {
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
$tagid = System::baseUrl() . '/search?tag=' . $xterm;
|
$tagid = System::baseUrl() . '/search?tag=' . $xterm;
|
||||||
$objtype = ACTIVITY_OBJ_TAGTERM;
|
$objtype = Activity::OBJ_TAGTERM;
|
||||||
|
|
||||||
$obj = <<< EOT
|
$obj = <<< EOT
|
||||||
<object>
|
<object>
|
||||||
|
@ -130,7 +131,7 @@ EOT;
|
||||||
$plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]';
|
$plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]';
|
||||||
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink );
|
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink, $termlink );
|
||||||
|
|
||||||
$arr['verb'] = ACTIVITY_TAG;
|
$arr['verb'] = Activity::TAG;
|
||||||
$arr['target-type'] = $targettype;
|
$arr['target-type'] = $targettype;
|
||||||
$arr['target'] = $target;
|
$arr['target'] = $target;
|
||||||
$arr['object-type'] = $objtype;
|
$arr['object-type'] = $objtype;
|
||||||
|
|
|
@ -24,6 +24,7 @@ use Friendica\Model\Event;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\Map;
|
use Friendica\Util\Map;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\ParseUrl;
|
use Friendica\Util\ParseUrl;
|
||||||
|
@ -276,7 +277,7 @@ class BBCode extends BaseObject
|
||||||
|
|
||||||
if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
|
if (preg_match_all("(\[url=(.*?)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
|
||||||
if ((count($pictures) == 1) && !$has_title) {
|
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::OBJ_IMAGE)) {
|
||||||
// Replace the preview picture with the real picture
|
// Replace the preview picture with the real picture
|
||||||
$url = str_replace('-1.', '-0.', $pictures[0][2]);
|
$url = str_replace('-1.', '-0.', $pictures[0][2]);
|
||||||
$data = ['url' => $url, 'type' => 'photo'];
|
$data = ['url' => $url, 'type' => 'photo'];
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
@ -250,7 +251,7 @@ class NotificationsManager extends BaseObject
|
||||||
|
|
||||||
// Transform the different types of notification in an usable array
|
// Transform the different types of notification in an usable array
|
||||||
switch ($it['verb']) {
|
switch ($it['verb']) {
|
||||||
case ACTIVITY_LIKE:
|
case Activity::LIKE:
|
||||||
$notif = [
|
$notif = [
|
||||||
'label' => 'like',
|
'label' => 'like',
|
||||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||||
|
@ -263,7 +264,7 @@ class NotificationsManager extends BaseObject
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTIVITY_DISLIKE:
|
case Activity::DISLIKE:
|
||||||
$notif = [
|
$notif = [
|
||||||
'label' => 'dislike',
|
'label' => 'dislike',
|
||||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||||
|
@ -276,7 +277,7 @@ class NotificationsManager extends BaseObject
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTIVITY_ATTEND:
|
case Activity::ATTEND:
|
||||||
$notif = [
|
$notif = [
|
||||||
'label' => 'attend',
|
'label' => 'attend',
|
||||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||||
|
@ -289,7 +290,7 @@ class NotificationsManager extends BaseObject
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTIVITY_ATTENDNO:
|
case Activity::ATTENDNO:
|
||||||
$notif = [
|
$notif = [
|
||||||
'label' => 'attendno',
|
'label' => 'attendno',
|
||||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||||
|
@ -302,7 +303,7 @@ class NotificationsManager extends BaseObject
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTIVITY_ATTENDMAYBE:
|
case Activity::ATTENDMAYBE:
|
||||||
$notif = [
|
$notif = [
|
||||||
'label' => 'attendmaybe',
|
'label' => 'attendmaybe',
|
||||||
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
'link' => System::baseUrl(true) . '/display/' . $it['parent-guid'],
|
||||||
|
@ -315,7 +316,7 @@ class NotificationsManager extends BaseObject
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTIVITY_FRIEND:
|
case Activity::FRIEND:
|
||||||
if (!isset($it['object'])) {
|
if (!isset($it['object'])) {
|
||||||
$notif = [
|
$notif = [
|
||||||
'label' => 'friend',
|
'label' => 'friend',
|
||||||
|
|
|
@ -18,6 +18,7 @@ use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\DFRN;
|
use Friendica\Protocol\DFRN;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
|
@ -828,7 +829,7 @@ class Contact extends BaseObject
|
||||||
} elseif (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
} elseif (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||||
// create an unfollow slap
|
// create an unfollow slap
|
||||||
$item = [];
|
$item = [];
|
||||||
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
|
$item['verb'] = Activity\Namespaces::OSTATUS . "/unfollow";
|
||||||
$item['follow'] = $contact["url"];
|
$item['follow'] = $contact["url"];
|
||||||
$item['body'] = '';
|
$item['body'] = '';
|
||||||
$item['title'] = '';
|
$item['title'] = '';
|
||||||
|
@ -2366,7 +2367,7 @@ class Contact extends BaseObject
|
||||||
if (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
if (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||||
// create a follow slap
|
// create a follow slap
|
||||||
$item = [];
|
$item = [];
|
||||||
$item['verb'] = ACTIVITY_FOLLOW;
|
$item['verb'] = Activity::FOLLOW;
|
||||||
$item['follow'] = $contact["url"];
|
$item['follow'] = $contact["url"];
|
||||||
$item['body'] = '';
|
$item['body'] = '';
|
||||||
$item['title'] = '';
|
$item['title'] = '';
|
||||||
|
@ -2568,7 +2569,7 @@ class Contact extends BaseObject
|
||||||
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
|
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
|
||||||
'source_link' => $contact_record['url'],
|
'source_link' => $contact_record['url'],
|
||||||
'source_photo' => $contact_record['photo'],
|
'source_photo' => $contact_record['photo'],
|
||||||
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
|
'verb' => ($sharing ? Activity::FRIEND : Activity::FOLLOW),
|
||||||
'otype' => 'intro'
|
'otype' => 'intro'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Map;
|
use Friendica\Util\Map;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -303,7 +304,7 @@ class Event extends BaseObject
|
||||||
|
|
||||||
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
||||||
if (DBA::isResult($item)) {
|
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::OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||||
$object .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
$object .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||||
$object .= '</object>' . "\n";
|
$object .= '</object>' . "\n";
|
||||||
|
|
||||||
|
@ -350,13 +351,13 @@ class Event extends BaseObject
|
||||||
$item_arr['deny_gid'] = $event['deny_gid'];
|
$item_arr['deny_gid'] = $event['deny_gid'];
|
||||||
$item_arr['private'] = $private;
|
$item_arr['private'] = $private;
|
||||||
$item_arr['visible'] = 1;
|
$item_arr['visible'] = 1;
|
||||||
$item_arr['verb'] = ACTIVITY_POST;
|
$item_arr['verb'] = Activity::POST;
|
||||||
$item_arr['object-type'] = ACTIVITY_OBJ_EVENT;
|
$item_arr['object-type'] = Activity::OBJ_EVENT;
|
||||||
$item_arr['origin'] = $event['cid'] === 0 ? 1 : 0;
|
$item_arr['origin'] = $event['cid'] === 0 ? 1 : 0;
|
||||||
$item_arr['body'] = self::getBBCode($event);
|
$item_arr['body'] = self::getBBCode($event);
|
||||||
$item_arr['event-id'] = $event['id'];
|
$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::OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||||
$item_arr['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
$item_arr['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||||
$item_arr['object'] .= '</object>' . "\n";
|
$item_arr['object'] .= '</object>' . "\n";
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,11 @@ class Item extends BaseObject
|
||||||
|
|
||||||
// Never reorder or remove entries from this list. Just add new ones at the end, if needed.
|
// Never reorder or remove entries from this list. Just add new ones at the end, if needed.
|
||||||
// The item-activity table only stores the index and needs this array to know the matching activity.
|
// The item-activity table only stores the index and needs this array to know the matching activity.
|
||||||
const ACTIVITIES = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_FOLLOW, ACTIVITY2_ANNOUNCE];
|
const ACTIVITIES = [
|
||||||
|
Activity::LIKE, Activity::DISLIKE,
|
||||||
|
Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE,
|
||||||
|
Activity::FOLLOW,
|
||||||
|
Activity::ANNOUNCE];
|
||||||
|
|
||||||
private static $legacy_mode = null;
|
private static $legacy_mode = null;
|
||||||
|
|
||||||
|
@ -210,9 +214,9 @@ class Item extends BaseObject
|
||||||
$row['object'] = '';
|
$row['object'] = '';
|
||||||
}
|
}
|
||||||
if (array_key_exists('object-type', $row)) {
|
if (array_key_exists('object-type', $row)) {
|
||||||
$row['object-type'] = ACTIVITY_OBJ_NOTE;
|
$row['object-type'] = Activity::OBJ_NOTE;
|
||||||
}
|
}
|
||||||
} elseif (array_key_exists('verb', $row) && in_array($row['verb'], ['', ACTIVITY_POST, ACTIVITY_SHARE])) {
|
} 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.
|
// Posts don't have an object or target - but having tags or files.
|
||||||
// We safe some performance by building tag and file strings only here.
|
// We safe some performance by building tag and file strings only here.
|
||||||
// We remove object and target since they aren't used for this type.
|
// We remove object and target since they aren't used for this type.
|
||||||
|
@ -224,7 +228,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists('verb', $row) || in_array($row['verb'], ['', ACTIVITY_POST, ACTIVITY_SHARE])) {
|
if (!array_key_exists('verb', $row) || in_array($row['verb'], ['', Activity::POST, Activity::SHARE])) {
|
||||||
// Build the tag string out of the term entries
|
// Build the tag string out of the term entries
|
||||||
if (array_key_exists('tag', $row) && empty($row['tag'])) {
|
if (array_key_exists('tag', $row) && empty($row['tag'])) {
|
||||||
$row['tag'] = Term::tagTextFromItemId($row['internal-iid']);
|
$row['tag'] = Term::tagTextFromItemId($row['internal-iid']);
|
||||||
|
@ -1153,14 +1157,14 @@ class Item extends BaseObject
|
||||||
|
|
||||||
private static function deleteTagsFromItem($item)
|
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::OBJ_TAGTERM)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xo = XML::parseString($item["object"], false);
|
$xo = XML::parseString($item["object"], false);
|
||||||
$xt = XML::parseString($item["target"], false);
|
$xt = XML::parseString($item["target"], false);
|
||||||
|
|
||||||
if ($xt->type != ACTIVITY_OBJ_NOTE) {
|
if ($xt->type != Activity::OBJ_NOTE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,9 +1370,9 @@ class Item extends BaseObject
|
||||||
$item['gravity'] = intval($item['gravity']);
|
$item['gravity'] = intval($item['gravity']);
|
||||||
} elseif ($item['parent-uri'] === $item['uri']) {
|
} elseif ($item['parent-uri'] === $item['uri']) {
|
||||||
$item['gravity'] = GRAVITY_PARENT;
|
$item['gravity'] = GRAVITY_PARENT;
|
||||||
} elseif ($activity->match($item['verb'], ACTIVITY_POST)) {
|
} elseif ($activity->match($item['verb'], Activity::POST)) {
|
||||||
$item['gravity'] = GRAVITY_COMMENT;
|
$item['gravity'] = GRAVITY_COMMENT;
|
||||||
} elseif ($activity->match($item['verb'], ACTIVITY_FOLLOW)) {
|
} elseif ($activity->match($item['verb'], Activity::FOLLOW)) {
|
||||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||||
} else {
|
} else {
|
||||||
$item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
|
$item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
|
||||||
|
@ -1564,14 +1568,14 @@ class Item extends BaseObject
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['verb'] == ACTIVITY_FOLLOW) {
|
if ($item['verb'] == Activity::FOLLOW) {
|
||||||
if (!$item['origin'] && ($item['author-id'] == Contact::getPublicIdByUserId($uid))) {
|
if (!$item['origin'] && ($item['author-id'] == Contact::getPublicIdByUserId($uid))) {
|
||||||
// Our own follow request can be relayed to us. We don't store it to avoid notification chaos.
|
// Our own follow request can be relayed to us. We don't store it to avoid notification chaos.
|
||||||
Logger::log("Follow: Don't store not origin follow request from us for " . $item['parent-uri'], Logger::DEBUG);
|
Logger::log("Follow: Don't store not origin follow request from us for " . $item['parent-uri'], Logger::DEBUG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ['verb' => ACTIVITY_FOLLOW, 'uid' => $item['uid'],
|
$condition = ['verb' => Activity::FOLLOW, 'uid' => $item['uid'],
|
||||||
'parent-uri' => $item['parent-uri'], 'author-id' => $item['author-id']];
|
'parent-uri' => $item['parent-uri'], 'author-id' => $item['author-id']];
|
||||||
if (self::exists($condition)) {
|
if (self::exists($condition)) {
|
||||||
// It happens that we receive multiple follow requests by the same author - we only store one.
|
// It happens that we receive multiple follow requests by the same author - we only store one.
|
||||||
|
@ -1678,7 +1682,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stristr($item['verb'], ACTIVITY_POKE)) {
|
if (stristr($item['verb'], Activity::POKE)) {
|
||||||
$notify_type = Delivery::POKE;
|
$notify_type = Delivery::POKE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2691,7 +2695,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only forward posts
|
// Only forward posts
|
||||||
if ($datarray["verb"] != ACTIVITY_POST) {
|
if ($datarray["verb"] != Activity::POST) {
|
||||||
Logger::log('No post', Logger::DEBUG);
|
Logger::log('No post', Logger::DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3044,23 +3048,23 @@ class Item extends BaseObject
|
||||||
switch ($verb) {
|
switch ($verb) {
|
||||||
case 'like':
|
case 'like':
|
||||||
case 'unlike':
|
case 'unlike':
|
||||||
$activity = ACTIVITY_LIKE;
|
$activity = Activity::LIKE;
|
||||||
break;
|
break;
|
||||||
case 'dislike':
|
case 'dislike':
|
||||||
case 'undislike':
|
case 'undislike':
|
||||||
$activity = ACTIVITY_DISLIKE;
|
$activity = Activity::DISLIKE;
|
||||||
break;
|
break;
|
||||||
case 'attendyes':
|
case 'attendyes':
|
||||||
case 'unattendyes':
|
case 'unattendyes':
|
||||||
$activity = ACTIVITY_ATTEND;
|
$activity = Activity::ATTEND;
|
||||||
break;
|
break;
|
||||||
case 'attendno':
|
case 'attendno':
|
||||||
case 'unattendno':
|
case 'unattendno':
|
||||||
$activity = ACTIVITY_ATTENDNO;
|
$activity = Activity::ATTENDNO;
|
||||||
break;
|
break;
|
||||||
case 'attendmaybe':
|
case 'attendmaybe':
|
||||||
case 'unattendmaybe':
|
case 'unattendmaybe':
|
||||||
$activity = ACTIVITY_ATTENDMAYBE;
|
$activity = Activity::ATTENDMAYBE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Logger::log('like: unknown verb ' . $verb . ' for item ' . $item_id);
|
Logger::log('like: unknown verb ' . $verb . ' for item ' . $item_id);
|
||||||
|
@ -3068,7 +3072,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable activity toggling instead of on/off
|
// Enable activity toggling instead of on/off
|
||||||
$event_verb_flag = $activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE;
|
$event_verb_flag = $activity === Activity::ATTEND || $activity === Activity::ATTENDNO || $activity === Activity::ATTENDMAYBE;
|
||||||
|
|
||||||
Logger::log('like: verb ' . $verb . ' item ' . $item_id);
|
Logger::log('like: verb ' . $verb . ' item ' . $item_id);
|
||||||
|
|
||||||
|
@ -3122,7 +3126,7 @@ class Item extends BaseObject
|
||||||
// event participation are essentially radio toggles. If you make a subsequent choice,
|
// event participation are essentially radio toggles. If you make a subsequent choice,
|
||||||
// we need to eradicate your first choice.
|
// we need to eradicate your first choice.
|
||||||
if ($event_verb_flag) {
|
if ($event_verb_flag) {
|
||||||
$verbs = [ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE];
|
$verbs = [Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE];
|
||||||
|
|
||||||
// Translate to the index based activity index
|
// Translate to the index based activity index
|
||||||
$activities = [];
|
$activities = [];
|
||||||
|
@ -3152,7 +3156,7 @@ class Item extends BaseObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE;
|
$objtype = $item['resource-id'] ? Activity::OBJ_IMAGE : Activity::OBJ_NOTE;
|
||||||
|
|
||||||
$new_item = [
|
$new_item = [
|
||||||
'guid' => System::createUUID(),
|
'guid' => System::createUUID(),
|
||||||
|
@ -3318,7 +3322,7 @@ class Item extends BaseObject
|
||||||
return L10n::t('event');
|
return L10n::t('event');
|
||||||
} elseif (!empty($item['resource-id'])) {
|
} elseif (!empty($item['resource-id'])) {
|
||||||
return L10n::t('photo');
|
return L10n::t('photo');
|
||||||
} elseif (!empty($item['verb']) && $item['verb'] !== ACTIVITY_POST) {
|
} elseif (!empty($item['verb']) && $item['verb'] !== Activity::POST) {
|
||||||
return L10n::t('activity');
|
return L10n::t('activity');
|
||||||
} elseif ($item['id'] != $item['parent']) {
|
} elseif ($item['id'] != $item['parent']) {
|
||||||
return L10n::t('comment');
|
return L10n::t('comment');
|
||||||
|
@ -3432,7 +3436,7 @@ class Item extends BaseObject
|
||||||
|
|
||||||
// In order to provide theme developers more possibilities, event items
|
// In order to provide theme developers more possibilities, event items
|
||||||
// are treated differently.
|
// are treated differently.
|
||||||
if ($item['object-type'] === ACTIVITY_OBJ_EVENT && isset($item['event-id'])) {
|
if ($item['object-type'] === Activity::OBJ_EVENT && isset($item['event-id'])) {
|
||||||
$ev = Event::getItemHTML($item);
|
$ev = Event::getItemHTML($item);
|
||||||
return $ev;
|
return $ev;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Model\Item;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Worker\Delivery;
|
use Friendica\Worker\Delivery;
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ class Mail
|
||||||
'source_name' => $msg['from-name'],
|
'source_name' => $msg['from-name'],
|
||||||
'source_link' => $msg['from-url'],
|
'source_link' => $msg['from-url'],
|
||||||
'source_photo' => $msg['from-photo'],
|
'source_photo' => $msg['from-photo'],
|
||||||
'verb' => ACTIVITY_POST,
|
'verb' => Activity::POST,
|
||||||
'otype' => 'mail'
|
'otype' => 'mail'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Friendica\Core\System;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\Diaspora;
|
use Friendica\Protocol\Diaspora;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
@ -692,7 +693,7 @@ class Profile
|
||||||
|
|
||||||
while ($rr = DBA::fetch($s)) {
|
while ($rr = DBA::fetch($s)) {
|
||||||
$condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => public_contact(),
|
$condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => public_contact(),
|
||||||
'activity' => [Item::activityToIndex(ACTIVITY_ATTEND), Item::activityToIndex(ACTIVITY_ATTENDMAYBE)],
|
'activity' => [Item::activityToIndex( Activity::ATTEND), Item::activityToIndex(Activity::ATTENDMAYBE)],
|
||||||
'visible' => true, 'deleted' => false];
|
'visible' => true, 'deleted' => false];
|
||||||
if (!Item::exists($condition)) {
|
if (!Item::exists($condition)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Protocol\Salmon;
|
use Friendica\Protocol\Salmon;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -95,11 +96,11 @@ class Xrd extends BaseModule
|
||||||
],
|
],
|
||||||
'links' => [
|
'links' => [
|
||||||
[
|
[
|
||||||
'rel' => NAMESPACE_DFRN,
|
'rel' => Namespaces::DFRN ,
|
||||||
'href' => $owner['url'],
|
'href' => $owner['url'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => NAMESPACE_FEED,
|
'rel' => Namespaces::FEED,
|
||||||
'type' => 'application/atom+xml',
|
'type' => 'application/atom+xml',
|
||||||
'href' => $owner['poll'],
|
'href' => $owner['poll'],
|
||||||
],
|
],
|
||||||
|
@ -119,7 +120,7 @@ class Xrd extends BaseModule
|
||||||
'href' => $baseURL . '/hcard/' . $owner['nickname'],
|
'href' => $baseURL . '/hcard/' . $owner['nickname'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => NAMESPACE_POCO,
|
'rel' => Namespaces::POCO,
|
||||||
'href' => $owner['poco'],
|
'href' => $owner['poco'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
|
@ -18,6 +18,7 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\Email;
|
use Friendica\Protocol\Email;
|
||||||
use Friendica\Protocol\Feed;
|
use Friendica\Protocol\Feed;
|
||||||
|
@ -200,10 +201,10 @@ class Probe
|
||||||
Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), Logger::DATA);
|
Logger::log('webfingerDfrn: '.$webbie.':'.print_r($links, true), Logger::DATA);
|
||||||
if (!empty($links) && is_array($links)) {
|
if (!empty($links) && is_array($links)) {
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
if ($link['@attributes']['rel'] === NAMESPACE_DFRN) {
|
if ($link['@attributes']['rel'] === Namespaces::DFRN) {
|
||||||
$profile_link = $link['@attributes']['href'];
|
$profile_link = $link['@attributes']['href'];
|
||||||
}
|
}
|
||||||
if (($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB) && ($profile_link == "")) {
|
if (($link['@attributes']['rel'] === Namespaces::OSTATUSSUB) && ($profile_link == "")) {
|
||||||
$profile_link = 'stat:'.$link['@attributes']['template'];
|
$profile_link = 'stat:'.$link['@attributes']['template'];
|
||||||
}
|
}
|
||||||
if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
|
if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
|
||||||
|
@ -492,7 +493,7 @@ class Probe
|
||||||
$has_key = false;
|
$has_key = false;
|
||||||
|
|
||||||
foreach ($webfinger['links'] as $link) {
|
foreach ($webfinger['links'] as $link) {
|
||||||
if ($link['rel'] == NAMESPACE_OSTATUSSUB) {
|
if ($link['rel'] == Namespaces::OSTATUSSUB) {
|
||||||
$is_ostatus = true;
|
$is_ostatus = true;
|
||||||
}
|
}
|
||||||
if ($link['rel'] == 'magic-public-key') {
|
if ($link['rel'] == 'magic-public-key') {
|
||||||
|
@ -955,15 +956,15 @@ class Probe
|
||||||
// The array is reversed to take into account the order of preference for same-rel links
|
// The array is reversed to take into account the order of preference for same-rel links
|
||||||
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
// See: https://tools.ietf.org/html/rfc7033#section-4.4.4
|
||||||
foreach (array_reverse($webfinger["links"]) as $link) {
|
foreach (array_reverse($webfinger["links"]) as $link) {
|
||||||
if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) {
|
if (($link["rel"] == Namespaces::DFRN) && !empty($link["href"])) {
|
||||||
$data["network"] = Protocol::DFRN;
|
$data["network"] = Protocol::DFRN;
|
||||||
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
} elseif (($link["rel"] == Namespaces::FEED) && !empty($link["href"])) {
|
||||||
$data["poll"] = $link["href"];
|
$data["poll"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) {
|
||||||
$hcard_url = $link["href"];
|
$hcard_url = $link["href"];
|
||||||
} elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
|
} elseif (($link["rel"] == Namespaces::POCO) && !empty($link["href"])) {
|
||||||
$data["poco"] = $link["href"];
|
$data["poco"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) {
|
||||||
$data["photo"] = $link["href"];
|
$data["photo"] = $link["href"];
|
||||||
|
@ -1171,9 +1172,9 @@ class Probe
|
||||||
$data["guid"] = $link["href"];
|
$data["guid"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
} elseif (($link["rel"] == Namespaces::FEED) && !empty($link["href"])) {
|
||||||
$data["poll"] = $link["href"];
|
$data["poll"] = $link["href"];
|
||||||
} elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) {
|
} elseif (($link["rel"] == Namespaces::POCO) && !empty($link["href"])) {
|
||||||
$data["poco"] = $link["href"];
|
$data["poco"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
|
||||||
$data["notify"] = $link["href"];
|
$data["notify"] = $link["href"];
|
||||||
|
@ -1273,7 +1274,7 @@ class Probe
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "salmon") && !empty($link["href"])) {
|
||||||
$data["notify"] = $link["href"];
|
$data["notify"] = $link["href"];
|
||||||
} elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) {
|
} elseif (($link["rel"] == Namespaces::FEED) && !empty($link["href"])) {
|
||||||
$data["poll"] = $link["href"];
|
$data["poll"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) {
|
||||||
$pubkey = $link["href"];
|
$pubkey = $link["href"];
|
||||||
|
|
|
@ -240,7 +240,7 @@ class Post extends BaseObject
|
||||||
|
|
||||||
$isevent = false;
|
$isevent = false;
|
||||||
$attend = [];
|
$attend = [];
|
||||||
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
|
if ($item['object-type'] === Activity::OBJ_EVENT) {
|
||||||
$response_verbs[] = 'attendyes';
|
$response_verbs[] = 'attendyes';
|
||||||
$response_verbs[] = 'attendno';
|
$response_verbs[] = 'attendno';
|
||||||
$response_verbs[] = 'attendmaybe';
|
$response_verbs[] = 'attendmaybe';
|
||||||
|
@ -531,8 +531,8 @@ class Post extends BaseObject
|
||||||
*/
|
*/
|
||||||
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
|
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
|
||||||
return false;
|
return false;
|
||||||
} elseif ($activity->match($item->getDataValue('verb'), ACTIVITY_LIKE) ||
|
} elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
|
||||||
$activity->match($item->getDataValue('verb'), ACTIVITY_DISLIKE)) {
|
$activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace Friendica\Object;
|
||||||
use Friendica\BaseObject;
|
use Friendica\BaseObject;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\Security;
|
use Friendica\Util\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,7 +155,7 @@ class Thread extends BaseObject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->getDataValue('verb') === ACTIVITY_LIKE || $item->getDataValue('verb') === ACTIVITY_DISLIKE) {
|
if ($item->getDataValue('verb') === Activity::LIKE || $item->getDataValue('verb') === Activity::DISLIKE) {
|
||||||
Logger::log('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', Logger::DEBUG);
|
Logger::log('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', Logger::DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,85 @@
|
||||||
|
|
||||||
namespace Friendica\Protocol;
|
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
|
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.
|
* Compare activity uri. Knows about activity namespace.
|
||||||
*
|
*
|
||||||
|
@ -15,9 +89,10 @@ final class Activity
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function match(string $haystack, string $needle) {
|
public function match(string $haystack, string $needle)
|
||||||
|
{
|
||||||
return (($haystack === $needle) ||
|
return (($haystack === $needle) ||
|
||||||
((basename($needle) === $haystack) &&
|
((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\Term;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Model\Mail;
|
use Friendica\Model\Mail;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\JsonLD;
|
use Friendica\Util\JsonLD;
|
||||||
|
@ -167,15 +168,15 @@ class Processor
|
||||||
public static function createItem($activity)
|
public static function createItem($activity)
|
||||||
{
|
{
|
||||||
$item = [];
|
$item = [];
|
||||||
$item['verb'] = ACTIVITY_POST;
|
$item['verb'] = Activity::POST;
|
||||||
$item['thr-parent'] = $activity['reply-to-id'];
|
$item['thr-parent'] = $activity['reply-to-id'];
|
||||||
|
|
||||||
if ($activity['reply-to-id'] == $activity['id']) {
|
if ($activity['reply-to-id'] == $activity['id']) {
|
||||||
$item['gravity'] = GRAVITY_PARENT;
|
$item['gravity'] = GRAVITY_PARENT;
|
||||||
$item['object-type'] = ACTIVITY_OBJ_NOTE;
|
$item['object-type'] = Activity::OBJ_NOTE;
|
||||||
} else {
|
} else {
|
||||||
$item['gravity'] = GRAVITY_COMMENT;
|
$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']])) {
|
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['verb'] = $verb;
|
||||||
$item['thr-parent'] = $activity['object_id'];
|
$item['thr-parent'] = $activity['object_id'];
|
||||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||||
$item['object-type'] = ACTIVITY_OBJ_NOTE;
|
$item['object-type'] = Activity::OBJ_NOTE;
|
||||||
|
|
||||||
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
|
$item['diaspora_signed_text'] = $activity['diaspora:like'] ?? '';
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Conversation;
|
use Friendica\Model\Conversation;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
|
@ -400,26 +401,26 @@ class Receiver
|
||||||
$announce_object_data['object_id'] = $object_data['object_id'];
|
$announce_object_data['object_id'] = $object_data['object_id'];
|
||||||
$announce_object_data['object_type'] = $object_data['object_type'];
|
$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;
|
break;
|
||||||
|
|
||||||
case 'as:Like':
|
case 'as:Like':
|
||||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
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;
|
break;
|
||||||
|
|
||||||
case 'as:Dislike':
|
case 'as:Dislike':
|
||||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
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;
|
break;
|
||||||
|
|
||||||
case 'as:TentativeAccept':
|
case 'as:TentativeAccept':
|
||||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
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;
|
break;
|
||||||
|
|
||||||
|
@ -444,7 +445,7 @@ class Receiver
|
||||||
ActivityPub\Processor::followUser($object_data);
|
ActivityPub\Processor::followUser($object_data);
|
||||||
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
||||||
$object_data['reply-to-id'] = $object_data['object_id'];
|
$object_data['reply-to-id'] = $object_data['object_id'];
|
||||||
ActivityPub\Processor::createActivity($object_data, ACTIVITY_FOLLOW);
|
ActivityPub\Processor::createActivity($object_data, Activity::FOLLOW);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -452,7 +453,7 @@ class Receiver
|
||||||
if ($object_data['object_type'] == 'as:Follow') {
|
if ($object_data['object_type'] == 'as:Follow') {
|
||||||
ActivityPub\Processor::acceptFollowUser($object_data);
|
ActivityPub\Processor::acceptFollowUser($object_data);
|
||||||
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
} 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;
|
break;
|
||||||
|
|
||||||
|
@ -460,7 +461,7 @@ class Receiver
|
||||||
if ($object_data['object_type'] == 'as:Follow') {
|
if ($object_data['object_type'] == 'as:Follow') {
|
||||||
ActivityPub\Processor::rejectFollowUser($object_data);
|
ActivityPub\Processor::rejectFollowUser($object_data);
|
||||||
} elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
|
} 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;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\HTTPSignature;
|
use Friendica\Util\HTTPSignature;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Model\Conversation;
|
use Friendica\Model\Conversation;
|
||||||
|
@ -761,25 +762,25 @@ class Transmitter
|
||||||
|
|
||||||
if ($reshared) {
|
if ($reshared) {
|
||||||
$type = 'Announce';
|
$type = 'Announce';
|
||||||
} elseif ($item['verb'] == ACTIVITY_POST) {
|
} elseif ($item['verb'] == Activity::POST) {
|
||||||
if ($item['created'] == $item['edited']) {
|
if ($item['created'] == $item['edited']) {
|
||||||
$type = 'Create';
|
$type = 'Create';
|
||||||
} else {
|
} else {
|
||||||
$type = 'Update';
|
$type = 'Update';
|
||||||
}
|
}
|
||||||
} elseif ($item['verb'] == ACTIVITY_LIKE) {
|
} elseif ($item['verb'] == Activity::LIKE) {
|
||||||
$type = 'Like';
|
$type = 'Like';
|
||||||
} elseif ($item['verb'] == ACTIVITY_DISLIKE) {
|
} elseif ($item['verb'] == Activity::DISLIKE) {
|
||||||
$type = 'Dislike';
|
$type = 'Dislike';
|
||||||
} elseif ($item['verb'] == ACTIVITY_ATTEND) {
|
} elseif ($item['verb'] == Activity::ATTEND) {
|
||||||
$type = 'Accept';
|
$type = 'Accept';
|
||||||
} elseif ($item['verb'] == ACTIVITY_ATTENDNO) {
|
} elseif ($item['verb'] == Activity::ATTENDNO) {
|
||||||
$type = 'Reject';
|
$type = 'Reject';
|
||||||
} elseif ($item['verb'] == ACTIVITY_ATTENDMAYBE) {
|
} elseif ($item['verb'] == Activity::ATTENDMAYBE) {
|
||||||
$type = 'TentativeAccept';
|
$type = 'TentativeAccept';
|
||||||
} elseif ($item['verb'] == ACTIVITY_FOLLOW) {
|
} elseif ($item['verb'] == Activity::FOLLOW) {
|
||||||
$type = 'Follow';
|
$type = 'Follow';
|
||||||
} elseif ($item['verb'] == ACTIVITY_TAG) {
|
} elseif ($item['verb'] == Activity::TAG) {
|
||||||
$type = 'Add';
|
$type = 'Add';
|
||||||
} else {
|
} else {
|
||||||
$type = '';
|
$type = '';
|
||||||
|
@ -1571,7 +1572,7 @@ class Transmitter
|
||||||
$uid = $first_user['uid'];
|
$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)];
|
'author-id' => Contact::getPublicIdByUserId($uid)];
|
||||||
if (Item::exists($condition)) {
|
if (Item::exists($condition)) {
|
||||||
Logger::log('Follow for ' . $object . ' for user ' . $uid . ' does already exist.', Logger::DEBUG);
|
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\Model\User;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Util\Crypto;
|
use Friendica\Util\Crypto;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
@ -382,18 +383,18 @@ class DFRN
|
||||||
$type = 'html';
|
$type = 'html';
|
||||||
|
|
||||||
if ($conversation) {
|
if ($conversation) {
|
||||||
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
|
$root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
|
||||||
$doc->appendChild($root);
|
$doc->appendChild($root);
|
||||||
|
|
||||||
$root->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
$root->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||||
$root->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
$root->setAttribute("xmlns:at", Namespaces::TOMB);
|
||||||
$root->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
$root->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||||
$root->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
$root->setAttribute("xmlns:dfrn", Namespaces::DFRN);
|
||||||
$root->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
$root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||||
$root->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
$root->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$root->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||||
|
|
||||||
//$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
|
//$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
|
||||||
|
|
||||||
|
@ -557,18 +558,18 @@ class DFRN
|
||||||
$alternatelink = $owner['url'];
|
$alternatelink = $owner['url'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
|
$root = $doc->createElementNS(Namespaces::ATOM1, 'feed');
|
||||||
$doc->appendChild($root);
|
$doc->appendChild($root);
|
||||||
|
|
||||||
$root->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
$root->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||||
$root->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
$root->setAttribute("xmlns:at", Namespaces::TOMB);
|
||||||
$root->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
$root->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||||
$root->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
$root->setAttribute("xmlns:dfrn", Namespaces::DFRN);
|
||||||
$root->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
$root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||||
$root->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
$root->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$root->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||||
|
|
||||||
XML::addElement($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
|
XML::addElement($doc, $root, "id", System::baseUrl()."/profile/".$owner["nick"]);
|
||||||
XML::addElement($doc, $root, "title", $owner["name"]);
|
XML::addElement($doc, $root, "title", $owner["name"]);
|
||||||
|
@ -941,18 +942,18 @@ class DFRN
|
||||||
if (!$single) {
|
if (!$single) {
|
||||||
$entry = $doc->createElement("entry");
|
$entry = $doc->createElement("entry");
|
||||||
} else {
|
} else {
|
||||||
$entry = $doc->createElementNS(NAMESPACE_ATOM1, 'entry');
|
$entry = $doc->createElementNS(Namespaces::ATOM1, 'entry');
|
||||||
$doc->appendChild($entry);
|
$doc->appendChild($entry);
|
||||||
|
|
||||||
$entry->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
$entry->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||||
$entry->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
$entry->setAttribute("xmlns:at", Namespaces::TOMB);
|
||||||
$entry->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
$entry->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||||
$entry->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
$entry->setAttribute("xmlns:dfrn", Namespaces::DFRN);
|
||||||
$entry->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
$entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||||
$entry->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
$entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||||
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$entry->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||||
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||||
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['private']) {
|
if ($item['private']) {
|
||||||
|
@ -1079,9 +1080,9 @@ class DFRN
|
||||||
if ($item['object-type'] != "") {
|
if ($item['object-type'] != "") {
|
||||||
XML::addElement($doc, $entry, "activity:object-type", $item['object-type']);
|
XML::addElement($doc, $entry, "activity:object-type", $item['object-type']);
|
||||||
} elseif ($item['id'] == $item['parent']) {
|
} 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 {
|
} 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']);
|
$actobj = self::createActivity($doc, "activity:object", $item['object']);
|
||||||
|
@ -1124,7 +1125,7 @@ class DFRN
|
||||||
"link",
|
"link",
|
||||||
"",
|
"",
|
||||||
["rel" => "mentioned",
|
["rel" => "mentioned",
|
||||||
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
|
"ostatus:object-type" => Activity::OBJ_GROUP,
|
||||||
"href" => $mention]
|
"href" => $mention]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1134,7 +1135,7 @@ class DFRN
|
||||||
"link",
|
"link",
|
||||||
"",
|
"",
|
||||||
["rel" => "mentioned",
|
["rel" => "mentioned",
|
||||||
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
|
"ostatus:object-type" => Activity::OBJ_PERSON,
|
||||||
"href" => $mention]
|
"href" => $mention]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1750,7 +1751,7 @@ class DFRN
|
||||||
$obj_doc = new DOMDocument("1.0", "utf-8");
|
$obj_doc = new DOMDocument("1.0", "utf-8");
|
||||||
$obj_doc->formatOutput = true;
|
$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;
|
$activity_type = $xpath->query("activity:object-type/text()", $activity)->item(0)->nodeValue;
|
||||||
XML::addElement($obj_doc, $obj_element, "type", $activity_type);
|
XML::addElement($obj_doc, $obj_element, "type", $activity_type);
|
||||||
|
@ -1907,7 +1908,7 @@ class DFRN
|
||||||
'source_name' => $importer['name'],
|
'source_name' => $importer['name'],
|
||||||
'source_link' => $importer['url'],
|
'source_link' => $importer['url'],
|
||||||
'source_photo' => $importer['photo'],
|
'source_photo' => $importer['photo'],
|
||||||
'verb' => ACTIVITY_REQ_FRIEND,
|
'verb' => Activity::REQ_FRIEND,
|
||||||
'otype' => 'intro']
|
'otype' => 'intro']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2117,7 +2118,7 @@ class DFRN
|
||||||
}
|
}
|
||||||
$xo = XML::parseString($item["object"], false);
|
$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?
|
// somebody was poked/prodded. Was it me?
|
||||||
$Blink = '';
|
$Blink = '';
|
||||||
foreach ($xo->link as $l) {
|
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.
|
// Big question: Do we need these functions? They were part of the "consume_feed" function.
|
||||||
// This function once was responsible for DFRN and OStatus.
|
// 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");
|
Logger::log("New follower");
|
||||||
Contact::addRelationship($importer, $contact, $item);
|
Contact::addRelationship($importer, $contact, $item);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($activity->match($item["verb"], ACTIVITY_UNFOLLOW)) {
|
if ($activity->match($item["verb"], Activity::UNFOLLOW)) {
|
||||||
Logger::log("Lost follower");
|
Logger::log("Lost follower");
|
||||||
Contact::removeFollower($importer, $contact, $item);
|
Contact::removeFollower($importer, $contact, $item);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($activity->match($item["verb"], ACTIVITY_REQ_FRIEND)) {
|
if ($activity->match($item["verb"], Activity::REQ_FRIEND)) {
|
||||||
Logger::log("New friend request");
|
Logger::log("New friend request");
|
||||||
Contact::addRelationship($importer, $contact, $item, true);
|
Contact::addRelationship($importer, $contact, $item, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($activity->match($item["verb"], ACTIVITY_UNFRIEND)) {
|
if ($activity->match($item["verb"], Activity::UNFRIEND)) {
|
||||||
Logger::log("Lost sharer");
|
Logger::log("Lost sharer");
|
||||||
Contact::removeSharer($importer, $contact, $item);
|
Contact::removeSharer($importer, $contact, $item);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (($item["verb"] == ACTIVITY_LIKE)
|
if (($item["verb"] == Activity::LIKE)
|
||||||
|| ($item["verb"] == ACTIVITY_DISLIKE)
|
|| ($item["verb"] == Activity::DISLIKE)
|
||||||
|| ($item["verb"] == ACTIVITY_ATTEND)
|
|| ($item["verb"] == Activity::ATTEND)
|
||||||
|| ($item["verb"] == ACTIVITY_ATTENDNO)
|
|| ($item["verb"] == Activity::ATTENDNO)
|
||||||
|| ($item["verb"] == ACTIVITY_ATTENDMAYBE)
|
|| ($item["verb"] == Activity::ATTENDMAYBE)
|
||||||
) {
|
) {
|
||||||
$is_like = true;
|
$is_like = true;
|
||||||
$item["gravity"] = GRAVITY_ACTIVITY;
|
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||||
|
@ -2238,11 +2239,11 @@ class DFRN
|
||||||
$is_like = false;
|
$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);
|
$xo = XML::parseString($item["object"], false);
|
||||||
$xt = XML::parseString($item["target"], 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"]]);
|
$item_tag = Item::selectFirst(['id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
|
||||||
|
|
||||||
if (!DBA::isResult($item_tag)) {
|
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
|
// 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 (in_array($entrytype, [DFRN::REPLY, DFRN::REPLY_RC])) {
|
||||||
if (!isset($item["object-type"])) {
|
if (!isset($item["object-type"])) {
|
||||||
$item["object-type"] = ACTIVITY_OBJ_COMMENT;
|
$item["object-type"] = Activity::OBJ_COMMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item["contact-id"] != $owner["contact-id"]) {
|
if ($item["contact-id"] != $owner["contact-id"]) {
|
||||||
|
@ -2541,11 +2542,11 @@ class DFRN
|
||||||
$item["wall"] = 1;
|
$item["wall"] = 1;
|
||||||
} elseif ($entrytype == DFRN::TOP_LEVEL) {
|
} elseif ($entrytype == DFRN::TOP_LEVEL) {
|
||||||
if (!isset($item["object-type"])) {
|
if (!isset($item["object-type"])) {
|
||||||
$item["object-type"] = ACTIVITY_OBJ_NOTE;
|
$item["object-type"] = Activity::OBJ_NOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is it an event?
|
// 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);
|
Logger::log("Item ".$item["uri"]." seems to contain an event.", Logger::DEBUG);
|
||||||
$ev = Event::fromBBCode($item["body"]);
|
$ev = Event::fromBBCode($item["body"]);
|
||||||
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
|
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
|
||||||
|
@ -2642,7 +2643,7 @@ class DFRN
|
||||||
Item::distribute($posted_id);
|
Item::distribute($posted_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stristr($item["verb"], ACTIVITY_POKE)) {
|
if (stristr($item["verb"], Activity::POKE)) {
|
||||||
$item['id'] = $posted_id;
|
$item['id'] = $posted_id;
|
||||||
self::doPoke($item, $importer);
|
self::doPoke($item, $importer);
|
||||||
}
|
}
|
||||||
|
@ -2731,16 +2732,16 @@ class DFRN
|
||||||
@$doc->loadXML($xml);
|
@$doc->loadXML($xml);
|
||||||
|
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
$xpath->registerNamespace("atom", NAMESPACE_ATOM1);
|
$xpath->registerNamespace("atom", Namespaces::ATOM1);
|
||||||
$xpath->registerNamespace("thr", NAMESPACE_THREAD);
|
$xpath->registerNamespace("thr", Namespaces::THREAD);
|
||||||
$xpath->registerNamespace("at", NAMESPACE_TOMB);
|
$xpath->registerNamespace("at", Namespaces::TOMB);
|
||||||
$xpath->registerNamespace("media", NAMESPACE_MEDIA);
|
$xpath->registerNamespace("media", Namespaces::MEDIA);
|
||||||
$xpath->registerNamespace("dfrn", NAMESPACE_DFRN);
|
$xpath->registerNamespace("dfrn", Namespaces::DFRN);
|
||||||
$xpath->registerNamespace("activity", NAMESPACE_ACTIVITY);
|
$xpath->registerNamespace("activity", Namespaces::ACTIVITY);
|
||||||
$xpath->registerNamespace("georss", NAMESPACE_GEORSS);
|
$xpath->registerNamespace("georss", Namespaces::GEORSS);
|
||||||
$xpath->registerNamespace("poco", NAMESPACE_POCO);
|
$xpath->registerNamespace("poco", Namespaces::POCO);
|
||||||
$xpath->registerNamespace("ostatus", NAMESPACE_OSTATUS);
|
$xpath->registerNamespace("ostatus", Namespaces::OSTATUS);
|
||||||
$xpath->registerNamespace("statusnet", NAMESPACE_STATUSNET);
|
$xpath->registerNamespace("statusnet", Namespaces::STATUSNET);
|
||||||
|
|
||||||
$header = [];
|
$header = [];
|
||||||
$header["uid"] = $importer["importer_uid"];
|
$header["uid"] = $importer["importer_uid"];
|
||||||
|
@ -2865,7 +2866,7 @@ class DFRN
|
||||||
if ($item['verb']) {
|
if ($item['verb']) {
|
||||||
return $item['verb'];
|
return $item['verb'];
|
||||||
}
|
}
|
||||||
return ACTIVITY_POST;
|
return Activity::POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function tgroupCheck($uid, $item)
|
private static function tgroupCheck($uid, $item)
|
||||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Model\Mail;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Util\Crypto;
|
use Friendica\Util\Crypto;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Map;
|
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
|
// Not sure if this cleaning is needed
|
||||||
$data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data);
|
$data = str_replace([" ", "\t", "\r", "\n"], ["", "", "", ""], $base->data);
|
||||||
|
@ -577,7 +578,7 @@ class Diaspora
|
||||||
$author_link = str_replace('acct:', '', $idom->author_id);
|
$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
|
// figure out where in the DOM tree our data is hiding
|
||||||
|
|
||||||
|
@ -1845,7 +1846,7 @@ class Diaspora
|
||||||
$datarray["guid"] = $guid;
|
$datarray["guid"] = $guid;
|
||||||
$datarray["uri"] = self::getUriFromGuid($author, $guid);
|
$datarray["uri"] = self::getUriFromGuid($author, $guid);
|
||||||
|
|
||||||
$datarray["verb"] = ACTIVITY_POST;
|
$datarray["verb"] = Activity::POST;
|
||||||
$datarray["gravity"] = GRAVITY_COMMENT;
|
$datarray["gravity"] = GRAVITY_COMMENT;
|
||||||
|
|
||||||
if ($thr_uri != "") {
|
if ($thr_uri != "") {
|
||||||
|
@ -1854,7 +1855,7 @@ class Diaspora
|
||||||
$datarray["parent-uri"] = $parent_item["uri"];
|
$datarray["parent-uri"] = $parent_item["uri"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_COMMENT;
|
$datarray["object-type"] = Activity::OBJ_COMMENT;
|
||||||
|
|
||||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||||
$datarray["source"] = $xml;
|
$datarray["source"] = $xml;
|
||||||
|
@ -2062,9 +2063,9 @@ class Diaspora
|
||||||
// "positive" = "false" would be a Dislike - wich isn't currently supported by Diaspora
|
// "positive" = "false" would be a Dislike - wich isn't currently supported by Diaspora
|
||||||
// We would accept this anyhow.
|
// We would accept this anyhow.
|
||||||
if ($positive == "true") {
|
if ($positive == "true") {
|
||||||
$verb = ACTIVITY_LIKE;
|
$verb = Activity::LIKE;
|
||||||
} else {
|
} else {
|
||||||
$verb = ACTIVITY_DISLIKE;
|
$verb = Activity::DISLIKE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$datarray = [];
|
$datarray = [];
|
||||||
|
@ -2085,7 +2086,7 @@ class Diaspora
|
||||||
$datarray["gravity"] = GRAVITY_ACTIVITY;
|
$datarray["gravity"] = GRAVITY_ACTIVITY;
|
||||||
$datarray["parent-uri"] = $parent_item["uri"];
|
$datarray["parent-uri"] = $parent_item["uri"];
|
||||||
|
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
$datarray["object-type"] = Activity::OBJ_NOTE;
|
||||||
|
|
||||||
$datarray["body"] = $verb;
|
$datarray["body"] = $verb;
|
||||||
|
|
||||||
|
@ -2684,9 +2685,9 @@ class Diaspora
|
||||||
$datarray['uri'] = self::getUriFromGuid($author, $datarray['guid']);
|
$datarray['uri'] = self::getUriFromGuid($author, $datarray['guid']);
|
||||||
$datarray['parent-uri'] = $parent['uri'];
|
$datarray['parent-uri'] = $parent['uri'];
|
||||||
|
|
||||||
$datarray['verb'] = $datarray['body'] = ACTIVITY2_ANNOUNCE;
|
$datarray['verb'] = $datarray['body'] = Activity::ANNOUNCE;
|
||||||
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
$datarray['gravity'] = GRAVITY_ACTIVITY;
|
||||||
$datarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
$datarray['object-type'] = Activity::OBJ_NOTE;
|
||||||
|
|
||||||
$datarray['protocol'] = $item['protocol'];
|
$datarray['protocol'] = $item['protocol'];
|
||||||
|
|
||||||
|
@ -2757,7 +2758,7 @@ class Diaspora
|
||||||
$datarray["guid"] = $guid;
|
$datarray["guid"] = $guid;
|
||||||
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
|
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
|
||||||
|
|
||||||
$datarray["verb"] = ACTIVITY_POST;
|
$datarray["verb"] = Activity::POST;
|
||||||
$datarray["gravity"] = GRAVITY_PARENT;
|
$datarray["gravity"] = GRAVITY_PARENT;
|
||||||
|
|
||||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||||
|
@ -2962,9 +2963,9 @@ class Diaspora
|
||||||
XML::unescape($photo->remote_photo_name)."[/img]\n".$body;
|
XML::unescape($photo->remote_photo_name)."[/img]\n".$body;
|
||||||
}
|
}
|
||||||
|
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_IMAGE;
|
$datarray["object-type"] = Activity::OBJ_IMAGE;
|
||||||
} else {
|
} else {
|
||||||
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;
|
$datarray["object-type"] = Activity::OBJ_NOTE;
|
||||||
|
|
||||||
// Add OEmbed and other information to the body
|
// Add OEmbed and other information to the body
|
||||||
if (!self::isRedmatrix($contact["url"])) {
|
if (!self::isRedmatrix($contact["url"])) {
|
||||||
|
@ -2994,7 +2995,7 @@ class Diaspora
|
||||||
$datarray["guid"] = $guid;
|
$datarray["guid"] = $guid;
|
||||||
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
|
$datarray["uri"] = $datarray["parent-uri"] = self::getUriFromGuid($author, $guid);
|
||||||
|
|
||||||
$datarray["verb"] = ACTIVITY_POST;
|
$datarray["verb"] = Activity::POST;
|
||||||
$datarray["gravity"] = GRAVITY_PARENT;
|
$datarray["gravity"] = GRAVITY_PARENT;
|
||||||
|
|
||||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||||
|
@ -3780,9 +3781,9 @@ class Diaspora
|
||||||
|
|
||||||
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
|
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
|
||||||
$positive = null;
|
$positive = null;
|
||||||
if ($item['verb'] === ACTIVITY_LIKE) {
|
if ($item['verb'] === Activity::LIKE) {
|
||||||
$positive = "true";
|
$positive = "true";
|
||||||
} elseif ($item['verb'] === ACTIVITY_DISLIKE) {
|
} elseif ($item['verb'] === Activity::DISLIKE) {
|
||||||
$positive = "false";
|
$positive = "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3811,13 +3812,13 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($item['verb']) {
|
switch ($item['verb']) {
|
||||||
case ACTIVITY_ATTEND:
|
case Activity::ATTEND:
|
||||||
$attend_answer = 'accepted';
|
$attend_answer = 'accepted';
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_ATTENDNO:
|
case Activity::ATTENDNO:
|
||||||
$attend_answer = 'declined';
|
$attend_answer = 'declined';
|
||||||
break;
|
break;
|
||||||
case ACTIVITY_ATTENDMAYBE:
|
case Activity::ATTENDMAYBE:
|
||||||
$attend_answer = 'tentative';
|
$attend_answer = 'tentative';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -3913,13 +3914,13 @@ class Diaspora
|
||||||
*/
|
*/
|
||||||
public static function sendFollowup(array $item, array $owner, array $contact, $public_batch = false)
|
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);
|
$message = self::constructAttend($item, $owner);
|
||||||
$type = "event_participation";
|
$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);
|
$message = self::constructLike($item, $owner);
|
||||||
$type = "like";
|
$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);
|
$message = self::constructComment($item, $owner);
|
||||||
$type = "comment";
|
$type = "comment";
|
||||||
}
|
}
|
||||||
|
@ -3948,7 +3949,7 @@ class Diaspora
|
||||||
$message = ["author" => $item['signer'],
|
$message = ["author" => $item['signer'],
|
||||||
"target_guid" => $signed_parts[0],
|
"target_guid" => $signed_parts[0],
|
||||||
"target_type" => $signed_parts[1]];
|
"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],
|
$message = ["author" => $signed_parts[4],
|
||||||
"guid" => $signed_parts[1],
|
"guid" => $signed_parts[1],
|
||||||
"parent_guid" => $signed_parts[3],
|
"parent_guid" => $signed_parts[3],
|
||||||
|
@ -3993,7 +3994,7 @@ class Diaspora
|
||||||
{
|
{
|
||||||
if ($item["deleted"]) {
|
if ($item["deleted"]) {
|
||||||
return self::sendRetraction($item, $owner, $contact, $public_batch, true);
|
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";
|
$type = "like";
|
||||||
} else {
|
} else {
|
||||||
$type = "comment";
|
$type = "comment";
|
||||||
|
@ -4054,7 +4055,7 @@ class Diaspora
|
||||||
|
|
||||||
if ($item['id'] == $item['parent']) {
|
if ($item['id'] == $item['parent']) {
|
||||||
$target_type = "Post";
|
$target_type = "Post";
|
||||||
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
} elseif (in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||||
$target_type = "Like";
|
$target_type = "Like";
|
||||||
} else {
|
} else {
|
||||||
$target_type = "Comment";
|
$target_type = "Comment";
|
||||||
|
@ -4320,7 +4321,7 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
|
if (!in_array($item["verb"], [Activity::LIKE, Activity::DISLIKE])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
|
@ -59,13 +60,13 @@ class Feed {
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadXML(trim($xml));
|
@$doc->loadXML(trim($xml));
|
||||||
$xpath = new DOMXPath($doc);
|
$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('dc', "http://purl.org/dc/elements/1.1/");
|
||||||
$xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/");
|
$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('rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
||||||
$xpath->registerNamespace('rss', "http://purl.org/rss/1.0/");
|
$xpath->registerNamespace('rss', "http://purl.org/rss/1.0/");
|
||||||
$xpath->registerNamespace('media', "http://search.yahoo.com/mrss/");
|
$xpath->registerNamespace('media', "http://search.yahoo.com/mrss/");
|
||||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
$xpath->registerNamespace('poco', Namespaces::POCO);
|
||||||
|
|
||||||
$author = [];
|
$author = [];
|
||||||
$entries = null;
|
$entries = null;
|
||||||
|
@ -198,8 +199,8 @@ class Feed {
|
||||||
$header["origin"] = 0;
|
$header["origin"] = 0;
|
||||||
$header["gravity"] = GRAVITY_PARENT;
|
$header["gravity"] = GRAVITY_PARENT;
|
||||||
$header["private"] = 2;
|
$header["private"] = 2;
|
||||||
$header["verb"] = ACTIVITY_POST;
|
$header["verb"] = Activity::POST;
|
||||||
$header["object-type"] = ACTIVITY_OBJ_NOTE;
|
$header["object-type"] = Activity::OBJ_NOTE;
|
||||||
|
|
||||||
$header["contact-id"] = $contact["id"];
|
$header["contact-id"] = $contact["id"];
|
||||||
|
|
||||||
|
@ -420,7 +421,7 @@ class Feed {
|
||||||
$item["title"] = "";
|
$item["title"] = "";
|
||||||
$item["body"] = $item["body"].add_page_info($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_blacklist"]);
|
$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["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"]);
|
unset($item["attach"]);
|
||||||
} else {
|
} else {
|
||||||
if (!empty($summary)) {
|
if (!empty($summary)) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Model\Item;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Protocol\Activity\Namespaces;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
|
@ -261,14 +262,14 @@ class OStatus
|
||||||
@$doc->loadXML($xml);
|
@$doc->loadXML($xml);
|
||||||
|
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||||
$xpath->registerNamespace('thr', NAMESPACE_THREAD);
|
$xpath->registerNamespace('thr', Namespaces::THREAD);
|
||||||
$xpath->registerNamespace('georss', NAMESPACE_GEORSS);
|
$xpath->registerNamespace('georss', Namespaces::GEORSS);
|
||||||
$xpath->registerNamespace('activity', NAMESPACE_ACTIVITY);
|
$xpath->registerNamespace('activity', Namespaces::ACTIVITY);
|
||||||
$xpath->registerNamespace('media', NAMESPACE_MEDIA);
|
$xpath->registerNamespace('media', Namespaces::MEDIA);
|
||||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
$xpath->registerNamespace('poco', Namespaces::POCO);
|
||||||
$xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
|
$xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
|
||||||
$xpath->registerNamespace('statusnet', NAMESPACE_STATUSNET);
|
$xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
|
||||||
|
|
||||||
$contact = ["id" => 0];
|
$contact = ["id" => 0];
|
||||||
|
|
||||||
|
@ -342,14 +343,14 @@ class OStatus
|
||||||
@$doc->loadXML($xml);
|
@$doc->loadXML($xml);
|
||||||
|
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||||
$xpath->registerNamespace('thr', NAMESPACE_THREAD);
|
$xpath->registerNamespace('thr', Namespaces::THREAD);
|
||||||
$xpath->registerNamespace('georss', NAMESPACE_GEORSS);
|
$xpath->registerNamespace('georss', Namespaces::GEORSS);
|
||||||
$xpath->registerNamespace('activity', NAMESPACE_ACTIVITY);
|
$xpath->registerNamespace('activity', Namespaces::ACTIVITY);
|
||||||
$xpath->registerNamespace('media', NAMESPACE_MEDIA);
|
$xpath->registerNamespace('media', Namespaces::MEDIA);
|
||||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
$xpath->registerNamespace('poco', Namespaces::POCO);
|
||||||
$xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
|
$xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
|
||||||
$xpath->registerNamespace('statusnet', NAMESPACE_STATUSNET);
|
$xpath->registerNamespace('statusnet', Namespaces::STATUSNET);
|
||||||
|
|
||||||
$hub = "";
|
$hub = "";
|
||||||
$hub_items = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0);
|
$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);
|
$item["verb"] = XML::getFirstNodeValue($xpath, 'activity:verb/text()', $entry);
|
||||||
|
|
||||||
// Delete a message
|
// 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);
|
self::deleteNotice($item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($item["verb"], [NAMESPACE_OSTATUS."/unfavorite", ACTIVITY_UNFAVORITE])) {
|
if (in_array($item["verb"], [Namespaces::OSTATUS . "/unfavorite", Activity::UNFAVORITE])) {
|
||||||
// Ignore "Unfavorite" message
|
// Ignore "Unfavorite" message
|
||||||
Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG);
|
Logger::log("Ignore unfavorite message ".print_r($item, true), Logger::DEBUG);
|
||||||
continue;
|
continue;
|
||||||
|
@ -447,7 +448,7 @@ class OStatus
|
||||||
Logger::log('Processing post with URI '.$item["uri"].' for user '.$importer["uid"].'.', Logger::DEBUG);
|
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
|
// ignore "Join" messages
|
||||||
Logger::log("Ignore join message ".print_r($item, true), Logger::DEBUG);
|
Logger::log("Ignore join message ".print_r($item, true), Logger::DEBUG);
|
||||||
continue;
|
continue;
|
||||||
|
@ -459,29 +460,29 @@ class OStatus
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item["verb"] == ACTIVITY_FOLLOW) {
|
if ($item["verb"] == Activity::FOLLOW) {
|
||||||
Contact::addRelationship($importer, $contact, $item);
|
Contact::addRelationship($importer, $contact, $item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item["verb"] == NAMESPACE_OSTATUS."/unfollow") {
|
if ($item["verb"] == Namespaces::OSTATUS."/unfollow") {
|
||||||
$dummy = null;
|
$dummy = null;
|
||||||
Contact::removeFollower($importer, $contact, $item, $dummy);
|
Contact::removeFollower($importer, $contact, $item, $dummy);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item["verb"] == ACTIVITY_FAVORITE) {
|
if ($item["verb"] == Activity::FAVORITE) {
|
||||||
$orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue;
|
$orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue;
|
||||||
Logger::log("Favorite ".$orig_uri." ".print_r($item, true));
|
Logger::log("Favorite ".$orig_uri." ".print_r($item, true));
|
||||||
|
|
||||||
$item["verb"] = ACTIVITY_LIKE;
|
$item["verb"] = Activity::LIKE;
|
||||||
$item["parent-uri"] = $orig_uri;
|
$item["parent-uri"] = $orig_uri;
|
||||||
$item["gravity"] = GRAVITY_ACTIVITY;
|
$item["gravity"] = GRAVITY_ACTIVITY;
|
||||||
$item["object-type"] = ACTIVITY_OBJ_NOTE;
|
$item["object-type"] = Activity::OBJ_NOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://activitystrea.ms/schema/1.0/rsvp-yes
|
// 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);
|
Logger::log("Unhandled verb ".$item["verb"]." ".print_r($item, true), Logger::DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,7 +505,7 @@ class OStatus
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
// Never post a thread when the only interaction by our contact was a like
|
// Never post a thread when the only interaction by our contact was a like
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$verbs = [ACTIVITY_POST, ACTIVITY_SHARE];
|
$verbs = [Activity::POST, Activity::SHARE];
|
||||||
foreach (self::$itemlist as $item) {
|
foreach (self::$itemlist as $item) {
|
||||||
if (in_array($item['verb'], $verbs) && Contact::isSharingByURL($item['author-link'], $item['uid'])) {
|
if (in_array($item['verb'], $verbs) && Contact::isSharingByURL($item['author-link'], $item['uid'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
@ -592,10 +593,10 @@ class OStatus
|
||||||
{
|
{
|
||||||
$item["body"] = HTML::toBBCode(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
|
$item["body"] = HTML::toBBCode(XML::getFirstNodeValue($xpath, 'atom:content/text()', $entry));
|
||||||
$item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/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["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
|
||||||
$item["body"] = XML::getFirstNodeValue($xpath, 'atom:summary/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);
|
$item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +677,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Is it a repeated post?
|
// 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);
|
$link_data = self::processRepeatedItem($xpath, $entry, $item, $importer);
|
||||||
if (!empty($link_data['add_body'])) {
|
if (!empty($link_data['add_body'])) {
|
||||||
$add_body .= $link_data['add_body'];
|
$add_body .= $link_data['add_body'];
|
||||||
|
@ -691,7 +692,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mastodon Content Warning
|
// 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);
|
$clear_text = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $entry);
|
||||||
if (!empty($clear_text)) {
|
if (!empty($clear_text)) {
|
||||||
$item['content-warning'] = HTML::toBBCode($clear_text);
|
$item['content-warning'] = HTML::toBBCode($clear_text);
|
||||||
|
@ -803,9 +804,9 @@ class OStatus
|
||||||
@$doc->loadXML($xml);
|
@$doc->loadXML($xml);
|
||||||
|
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
|
$xpath->registerNamespace('atom', Namespaces::ATOM1);
|
||||||
$xpath->registerNamespace('thr', NAMESPACE_THREAD);
|
$xpath->registerNamespace('thr', Namespaces::THREAD);
|
||||||
$xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS);
|
$xpath->registerNamespace('ostatus', Namespaces::OSTATUS);
|
||||||
|
|
||||||
$entries = $xpath->query('/atom:feed/atom:entry');
|
$entries = $xpath->query('/atom:feed/atom:entry');
|
||||||
|
|
||||||
|
@ -1067,7 +1068,7 @@ class OStatus
|
||||||
$item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $activityobject);
|
$item["object-type"] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $activityobject);
|
||||||
|
|
||||||
// Mastodon Content Warning
|
// 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);
|
$clear_text = XML::getFirstNodeValue($xpath, 'atom:summary/text()', $activityobject);
|
||||||
if (!empty($clear_text)) {
|
if (!empty($clear_text)) {
|
||||||
$item['content-warning'] = HTML::toBBCode($clear_text);
|
$item['content-warning'] = HTML::toBBCode($clear_text);
|
||||||
|
@ -1105,8 +1106,8 @@ class OStatus
|
||||||
switch ($attribute['rel']) {
|
switch ($attribute['rel']) {
|
||||||
case "alternate":
|
case "alternate":
|
||||||
$item["plink"] = $attribute['href'];
|
$item["plink"] = $attribute['href'];
|
||||||
if (($item["object-type"] == ACTIVITY_OBJ_QUESTION)
|
if (($item["object-type"] == Activity::OBJ_QUESTION)
|
||||||
|| ($item["object-type"] == ACTIVITY_OBJ_EVENT)
|
|| ($item["object-type"] == Activity::OBJ_EVENT)
|
||||||
) {
|
) {
|
||||||
$item["body"] .= add_page_info($attribute['href']);
|
$item["body"] .= add_page_info($attribute['href']);
|
||||||
}
|
}
|
||||||
|
@ -1135,7 +1136,7 @@ class OStatus
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "related":
|
case "related":
|
||||||
if ($item["object-type"] != ACTIVITY_OBJ_BOOKMARK) {
|
if ($item["object-type"] != Activity::OBJ_BOOKMARK) {
|
||||||
if (!isset($item["parent-uri"])) {
|
if (!isset($item["parent-uri"])) {
|
||||||
$item["parent-uri"] = $attribute['href'];
|
$item["parent-uri"] = $attribute['href'];
|
||||||
}
|
}
|
||||||
|
@ -1281,17 +1282,17 @@ class OStatus
|
||||||
*/
|
*/
|
||||||
private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
|
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);
|
$doc->appendChild($root);
|
||||||
|
|
||||||
$root->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
$root->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||||
$root->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
$root->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||||
$root->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
$root->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||||
$root->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
$root->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||||
$root->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$root->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||||
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
$root->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$selfUri = '/feed/' . $owner["nick"] . '/';
|
$selfUri = '/feed/' . $owner["nick"] . '/';
|
||||||
|
@ -1461,9 +1462,9 @@ class OStatus
|
||||||
$author = $doc->createElement("author");
|
$author = $doc->createElement("author");
|
||||||
XML::addElement($doc, $author, "id", $owner["url"]);
|
XML::addElement($doc, $author, "id", $owner["url"]);
|
||||||
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
|
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 {
|
} 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, "uri", $owner["url"]);
|
||||||
XML::addElement($doc, $author, "name", $owner["nick"]);
|
XML::addElement($doc, $author, "name", $owner["nick"]);
|
||||||
|
@ -1544,7 +1545,7 @@ class OStatus
|
||||||
return $item['verb'];
|
return $item['verb'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ACTIVITY_POST;
|
return Activity::POST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1556,11 +1557,11 @@ class OStatus
|
||||||
*/
|
*/
|
||||||
private static function constructObjecttype(array $item)
|
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 $item['object-type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ACTIVITY_OBJ_NOTE;
|
return Activity::OBJ_NOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1589,9 +1590,9 @@ class OStatus
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item["verb"] == ACTIVITY_LIKE) {
|
if ($item["verb"] == Activity::LIKE) {
|
||||||
return self::likeEntry($doc, $item, $owner, $toplevel);
|
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);
|
return self::followEntry($doc, $item, $owner, $toplevel);
|
||||||
} else {
|
} else {
|
||||||
return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
|
return self::noteEntry($doc, $item, $owner, $toplevel, $feed_mode);
|
||||||
|
@ -1705,11 +1706,11 @@ class OStatus
|
||||||
|
|
||||||
$title = $owner["nick"]." repeated a notice by ".$contact["nick"];
|
$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");
|
$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);
|
self::entryContent($doc, $as_object, $repeated_item, $owner, "", "", false);
|
||||||
|
|
||||||
|
@ -1759,7 +1760,7 @@ class OStatus
|
||||||
|
|
||||||
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
|
$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);
|
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
|
||||||
|
|
||||||
$parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]);
|
$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)
|
private static function addPersonObject(DOMDocument $doc, array $owner, array $contact)
|
||||||
{
|
{
|
||||||
$object = $doc->createElement("activity:object");
|
$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) {
|
if ($contact['network'] == Protocol::PHANTOM) {
|
||||||
XML::addElement($doc, $object, "id", $contact['url']);
|
XML::addElement($doc, $object, "id", $contact['url']);
|
||||||
|
@ -1858,7 +1859,7 @@ class OStatus
|
||||||
$connect_id = 0;
|
$connect_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['verb'] == ACTIVITY_FOLLOW) {
|
if ($item['verb'] == Activity::FOLLOW) {
|
||||||
$message = L10n::t('%s is now following %s.');
|
$message = L10n::t('%s is now following %s.');
|
||||||
$title = L10n::t('following');
|
$title = L10n::t('following');
|
||||||
$action = "subscription";
|
$action = "subscription";
|
||||||
|
@ -1918,7 +1919,7 @@ class OStatus
|
||||||
|
|
||||||
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
|
$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);
|
self::entryContent($doc, $entry, $item, $owner, $title, '', true, $feed_mode);
|
||||||
|
|
||||||
|
@ -1950,16 +1951,16 @@ class OStatus
|
||||||
$entry->appendChild($author);
|
$entry->appendChild($author);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$entry = $doc->createElementNS(NAMESPACE_ATOM1, "entry");
|
$entry = $doc->createElementNS(Namespaces::ATOM1, "entry");
|
||||||
|
|
||||||
$entry->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
$entry->setAttribute("xmlns:thr", Namespaces::THREAD);
|
||||||
$entry->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
$entry->setAttribute("xmlns:georss", Namespaces::GEORSS);
|
||||||
$entry->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
$entry->setAttribute("xmlns:activity", Namespaces::ACTIVITY);
|
||||||
$entry->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
$entry->setAttribute("xmlns:media", Namespaces::MEDIA);
|
||||||
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
$entry->setAttribute("xmlns:poco", Namespaces::POCO);
|
||||||
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$entry->setAttribute("xmlns:ostatus", Namespaces::OSTATUS);
|
||||||
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$entry->setAttribute("xmlns:statusnet", Namespaces::STATUSNET);
|
||||||
$entry->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
$entry->setAttribute("xmlns:mastodon", Namespaces::MASTODON);
|
||||||
|
|
||||||
$author = self::addAuthor($doc, $owner);
|
$author = self::addAuthor($doc, $owner);
|
||||||
$entry->appendChild($author);
|
$entry->appendChild($author);
|
||||||
|
@ -2111,14 +2112,14 @@ class OStatus
|
||||||
XML::addElement($doc, $entry, "link", "",
|
XML::addElement($doc, $entry, "link", "",
|
||||||
[
|
[
|
||||||
"rel" => "mentioned",
|
"rel" => "mentioned",
|
||||||
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
|
"ostatus:object-type" => Activity::OBJ_GROUP,
|
||||||
"href" => $mention]
|
"href" => $mention]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
XML::addElement($doc, $entry, "link", "",
|
XML::addElement($doc, $entry, "link", "",
|
||||||
[
|
[
|
||||||
"rel" => "mentioned",
|
"rel" => "mentioned",
|
||||||
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
|
"ostatus:object-type" => Activity::OBJ_PERSON,
|
||||||
"href" => $mention]
|
"href" => $mention]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2231,7 +2232,7 @@ class OStatus
|
||||||
|
|
||||||
if ($filter === 'comments') {
|
if ($filter === 'comments') {
|
||||||
$condition[0] .= " AND `object-type` = ? ";
|
$condition[0] .= " AND `object-type` = ? ";
|
||||||
$condition[] = ACTIVITY_OBJ_COMMENT;
|
$condition[] = Activity::OBJ_COMMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
if ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Protocol\ActivityPub;
|
use Friendica\Protocol\ActivityPub;
|
||||||
use Friendica\Protocol\Email;
|
use Friendica\Protocol\Email;
|
||||||
use Friendica\Protocol\PortableContact;
|
use Friendica\Protocol\PortableContact;
|
||||||
|
@ -493,8 +494,8 @@ class OnePoll
|
||||||
Logger::log("Mail: Parsing mail ".$msg_uid, Logger::DATA);
|
Logger::log("Mail: Parsing mail ".$msg_uid, Logger::DATA);
|
||||||
|
|
||||||
$datarray = [];
|
$datarray = [];
|
||||||
$datarray['verb'] = ACTIVITY_POST;
|
$datarray['verb'] = Activity::POST;
|
||||||
$datarray['object-type'] = ACTIVITY_OBJ_NOTE;
|
$datarray['object-type'] = Activity::OBJ_NOTE;
|
||||||
$datarray['network'] = Protocol::MAIL;
|
$datarray['network'] = Protocol::MAIL;
|
||||||
// $meta = Email::messageMeta($mbox, $msg_uid);
|
// $meta = Email::messageMeta($mbox, $msg_uid);
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,13 @@ class ActivityTest extends MockedTest
|
||||||
'assert' => true,
|
'assert' => true,
|
||||||
],
|
],
|
||||||
'simple' => [
|
'simple' => [
|
||||||
'haystack' => ACTIVITY_OBJ_TAGTERM,
|
'haystack' => Activity::OBJ_TAGTERM,
|
||||||
'needle' => ACTIVITY_OBJ_TAGTERM,
|
'needle' => Activity::OBJ_TAGTERM,
|
||||||
'assert' => true,
|
'assert' => true,
|
||||||
],
|
],
|
||||||
'withNamespace' => [
|
'withNamespace' => [
|
||||||
'haystack' => 'tagterm',
|
'haystack' => 'tagterm',
|
||||||
'needle' => NAMESPACE_ACTIVITY_SCHEMA . ACTIVITY_OBJ_TAGTERM,
|
'needle' => Activity\Namespaces::ACTIVITY_SCHEMA . Activity::OBJ_TAGTERM,
|
||||||
'assert' => true,
|
'assert' => true,
|
||||||
],
|
],
|
||||||
'invalidSimple' => [
|
'invalidSimple' => [
|
||||||
|
@ -32,12 +32,12 @@ class ActivityTest extends MockedTest
|
||||||
],
|
],
|
||||||
'invalidWithOutNamespace' => [
|
'invalidWithOutNamespace' => [
|
||||||
'haystack' => 'tagterm',
|
'haystack' => 'tagterm',
|
||||||
'needle' => ACTIVITY_OBJ_TAGTERM,
|
'needle' => Activity::OBJ_TAGTERM,
|
||||||
'assert' => false,
|
'assert' => false,
|
||||||
],
|
],
|
||||||
'withSubPath' => [
|
'withSubPath' => [
|
||||||
'haystack' => 'tagterm',
|
'haystack' => 'tagterm',
|
||||||
'needle' => NAMESPACE_ACTIVITY_SCHEMA . '/bla/' . ACTIVITY_OBJ_TAGTERM,
|
'needle' => Activity\Namespaces::ACTIVITY_SCHEMA . '/bla/' . Activity::OBJ_TAGTERM,
|
||||||
'assert' => true,
|
'assert' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -54,4 +54,12 @@ class ActivityTest extends MockedTest
|
||||||
|
|
||||||
$this->assertEquals($assert, $activity->match($haystack, $needle));
|
$this->assertEquals($assert, $activity->match($haystack, $needle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsHidden()
|
||||||
|
{
|
||||||
|
$activity = new Activity();
|
||||||
|
|
||||||
|
$this->assertTrue($activity->isHidden(Activity::LIKE));
|
||||||
|
$this->assertFalse($activity->isHidden(Activity::OBJ_BOOKMARK));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue