mirror of
https://github.com/friendica/friendica
synced 2025-04-29 09:44:23 +02: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
|
@ -18,6 +18,7 @@ use Friendica\Core\Worker;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
|
@ -828,7 +829,7 @@ class Contact extends BaseObject
|
|||
} elseif (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||
// create an unfollow slap
|
||||
$item = [];
|
||||
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
|
||||
$item['verb'] = Activity\Namespaces::OSTATUS . "/unfollow";
|
||||
$item['follow'] = $contact["url"];
|
||||
$item['body'] = '';
|
||||
$item['title'] = '';
|
||||
|
@ -2366,7 +2367,7 @@ class Contact extends BaseObject
|
|||
if (in_array($protocol, [Protocol::OSTATUS, Protocol::DFRN])) {
|
||||
// create a follow slap
|
||||
$item = [];
|
||||
$item['verb'] = ACTIVITY_FOLLOW;
|
||||
$item['verb'] = Activity::FOLLOW;
|
||||
$item['follow'] = $contact["url"];
|
||||
$item['body'] = '';
|
||||
$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_link' => $contact_record['url'],
|
||||
'source_photo' => $contact_record['photo'],
|
||||
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
|
||||
'verb' => ($sharing ? Activity::FRIEND : Activity::FOLLOW),
|
||||
'otype' => 'intro'
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use Friendica\Core\PConfig;
|
|||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -303,7 +304,7 @@ class Event extends BaseObject
|
|||
|
||||
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
||||
if (DBA::isResult($item)) {
|
||||
$object = '<object><type>' . XML::escape(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$object = '<object><type>' . XML::escape(Activity::OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$object .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$object .= '</object>' . "\n";
|
||||
|
||||
|
@ -350,13 +351,13 @@ class Event extends BaseObject
|
|||
$item_arr['deny_gid'] = $event['deny_gid'];
|
||||
$item_arr['private'] = $private;
|
||||
$item_arr['visible'] = 1;
|
||||
$item_arr['verb'] = ACTIVITY_POST;
|
||||
$item_arr['object-type'] = ACTIVITY_OBJ_EVENT;
|
||||
$item_arr['verb'] = Activity::POST;
|
||||
$item_arr['object-type'] = Activity::OBJ_EVENT;
|
||||
$item_arr['origin'] = $event['cid'] === 0 ? 1 : 0;
|
||||
$item_arr['body'] = self::getBBCode($event);
|
||||
$item_arr['event-id'] = $event['id'];
|
||||
|
||||
$item_arr['object'] = '<object><type>' . XML::escape(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item_arr['object'] = '<object><type>' . XML::escape(Activity::OBJ_EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item_arr['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$item_arr['object'] .= '</object>' . "\n";
|
||||
|
||||
|
|
|
@ -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.
|
||||
// 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;
|
||||
|
||||
|
@ -210,9 +214,9 @@ class Item extends BaseObject
|
|||
$row['object'] = '';
|
||||
}
|
||||
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.
|
||||
// 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.
|
||||
|
@ -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
|
||||
if (array_key_exists('tag', $row) && empty($row['tag'])) {
|
||||
$row['tag'] = Term::tagTextFromItemId($row['internal-iid']);
|
||||
|
@ -1153,14 +1157,14 @@ class Item extends BaseObject
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
$xo = XML::parseString($item["object"], false);
|
||||
$xt = XML::parseString($item["target"], false);
|
||||
|
||||
if ($xt->type != ACTIVITY_OBJ_NOTE) {
|
||||
if ($xt->type != Activity::OBJ_NOTE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1366,9 +1370,9 @@ class Item extends BaseObject
|
|||
$item['gravity'] = intval($item['gravity']);
|
||||
} elseif ($item['parent-uri'] === $item['uri']) {
|
||||
$item['gravity'] = GRAVITY_PARENT;
|
||||
} elseif ($activity->match($item['verb'], ACTIVITY_POST)) {
|
||||
} elseif ($activity->match($item['verb'], Activity::POST)) {
|
||||
$item['gravity'] = GRAVITY_COMMENT;
|
||||
} elseif ($activity->match($item['verb'], ACTIVITY_FOLLOW)) {
|
||||
} elseif ($activity->match($item['verb'], Activity::FOLLOW)) {
|
||||
$item['gravity'] = GRAVITY_ACTIVITY;
|
||||
} else {
|
||||
$item['gravity'] = GRAVITY_UNKNOWN; // Should not happen
|
||||
|
@ -1564,14 +1568,14 @@ class Item extends BaseObject
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($item['verb'] == ACTIVITY_FOLLOW) {
|
||||
if ($item['verb'] == Activity::FOLLOW) {
|
||||
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.
|
||||
Logger::log("Follow: Don't store not origin follow request from us for " . $item['parent-uri'], Logger::DEBUG);
|
||||
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']];
|
||||
if (self::exists($condition)) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -2691,7 +2695,7 @@ class Item extends BaseObject
|
|||
}
|
||||
|
||||
// Only forward posts
|
||||
if ($datarray["verb"] != ACTIVITY_POST) {
|
||||
if ($datarray["verb"] != Activity::POST) {
|
||||
Logger::log('No post', Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
@ -3044,23 +3048,23 @@ class Item extends BaseObject
|
|||
switch ($verb) {
|
||||
case 'like':
|
||||
case 'unlike':
|
||||
$activity = ACTIVITY_LIKE;
|
||||
$activity = Activity::LIKE;
|
||||
break;
|
||||
case 'dislike':
|
||||
case 'undislike':
|
||||
$activity = ACTIVITY_DISLIKE;
|
||||
$activity = Activity::DISLIKE;
|
||||
break;
|
||||
case 'attendyes':
|
||||
case 'unattendyes':
|
||||
$activity = ACTIVITY_ATTEND;
|
||||
$activity = Activity::ATTEND;
|
||||
break;
|
||||
case 'attendno':
|
||||
case 'unattendno':
|
||||
$activity = ACTIVITY_ATTENDNO;
|
||||
$activity = Activity::ATTENDNO;
|
||||
break;
|
||||
case 'attendmaybe':
|
||||
case 'unattendmaybe':
|
||||
$activity = ACTIVITY_ATTENDMAYBE;
|
||||
$activity = Activity::ATTENDMAYBE;
|
||||
break;
|
||||
default:
|
||||
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
|
||||
$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);
|
||||
|
||||
|
@ -3122,7 +3126,7 @@ class Item extends BaseObject
|
|||
// event participation are essentially radio toggles. If you make a subsequent choice,
|
||||
// we need to eradicate your first choice.
|
||||
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
|
||||
$activities = [];
|
||||
|
@ -3152,7 +3156,7 @@ class Item extends BaseObject
|
|||
return true;
|
||||
}
|
||||
|
||||
$objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE;
|
||||
$objtype = $item['resource-id'] ? Activity::OBJ_IMAGE : Activity::OBJ_NOTE;
|
||||
|
||||
$new_item = [
|
||||
'guid' => System::createUUID(),
|
||||
|
@ -3318,7 +3322,7 @@ class Item extends BaseObject
|
|||
return L10n::t('event');
|
||||
} elseif (!empty($item['resource-id'])) {
|
||||
return L10n::t('photo');
|
||||
} elseif (!empty($item['verb']) && $item['verb'] !== ACTIVITY_POST) {
|
||||
} elseif (!empty($item['verb']) && $item['verb'] !== Activity::POST) {
|
||||
return L10n::t('activity');
|
||||
} elseif ($item['id'] != $item['parent']) {
|
||||
return L10n::t('comment');
|
||||
|
@ -3432,7 +3436,7 @@ class Item extends BaseObject
|
|||
|
||||
// In order to provide theme developers more possibilities, event items
|
||||
// are treated differently.
|
||||
if ($item['object-type'] === ACTIVITY_OBJ_EVENT && isset($item['event-id'])) {
|
||||
if ($item['object-type'] === Activity::OBJ_EVENT && isset($item['event-id'])) {
|
||||
$ev = Event::getItemHTML($item);
|
||||
return $ev;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Photo;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Worker\Delivery;
|
||||
|
||||
|
@ -80,7 +81,7 @@ class Mail
|
|||
'source_name' => $msg['from-name'],
|
||||
'source_link' => $msg['from-url'],
|
||||
'source_photo' => $msg['from-photo'],
|
||||
'verb' => ACTIVITY_POST,
|
||||
'verb' => Activity::POST,
|
||||
'otype' => 'mail'
|
||||
];
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Theme;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -692,7 +693,7 @@ class Profile
|
|||
|
||||
while ($rr = DBA::fetch($s)) {
|
||||
$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];
|
||||
if (!Item::exists($condition)) {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue