2019-10-23 00:05:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Protocol;
|
|
|
|
|
2019-10-24 07:06:22 +00:00
|
|
|
use Friendica\Protocol\Activity\ANamespace;
|
2019-10-23 22:25:43 +00:00
|
|
|
|
2019-10-23 00:05:11 +00:00
|
|
|
/**
|
2019-10-24 07:06:22 +00:00
|
|
|
* Base class for the Activity constants and particular method
|
2019-10-23 00:05:11 +00:00
|
|
|
*/
|
|
|
|
final class Activity
|
|
|
|
{
|
2019-10-24 07:06:22 +00:00
|
|
|
const LIKE = ANamespace::ACTIVITY_SCHEMA . 'like';
|
2019-10-23 22:25:43 +00:00
|
|
|
|
2019-10-24 07:06:22 +00:00
|
|
|
const DISLIKE = ANamespace::DFRN . '/dislike';
|
|
|
|
const ATTEND = ANamespace::ZOT . '/activity/attendyes';
|
|
|
|
const ATTENDNO = ANamespace::ZOT . '/activity/attendno';
|
|
|
|
const ATTENDMAYBE = ANamespace::ZOT . '/activity/attendmaybe';
|
|
|
|
const OBJ_HEART = ANamespace::DFRN . '/heart';
|
2019-10-23 22:25:43 +00:00
|
|
|
|
2019-10-24 07:06:22 +00:00
|
|
|
const FRIEND = ANamespace::ACTIVITY_SCHEMA . 'make-friend';
|
|
|
|
const REQ_FRIEND = ANamespace::ACTIVITY_SCHEMA . 'request-friend';
|
|
|
|
const UNFRIEND = ANamespace::ACTIVITY_SCHEMA . 'remove-friend';
|
|
|
|
const FOLLOW = ANamespace::ACTIVITY_SCHEMA . 'follow';
|
|
|
|
const UNFOLLOW = ANamespace::ACTIVITY_SCHEMA . 'stop-following';
|
|
|
|
const JOIN = ANamespace::ACTIVITY_SCHEMA . 'join';
|
|
|
|
const POST = ANamespace::ACTIVITY_SCHEMA . 'post';
|
|
|
|
const UPDATE = ANamespace::ACTIVITY_SCHEMA . 'update';
|
|
|
|
const TAG = ANamespace::ACTIVITY_SCHEMA . 'tag';
|
|
|
|
const FAVORITE = ANamespace::ACTIVITY_SCHEMA . 'favorite';
|
|
|
|
const UNFAVORITE = ANamespace::ACTIVITY_SCHEMA . 'unfavorite';
|
|
|
|
const SHARE = ANamespace::ACTIVITY_SCHEMA . 'share';
|
|
|
|
const DELETE = ANamespace::ACTIVITY_SCHEMA . 'delete';
|
|
|
|
const ANNOUNCE = ANamespace::ACTIVITY2 . 'Announce';
|
2019-10-23 22:25:43 +00:00
|
|
|
|
2019-10-24 07:06:22 +00:00
|
|
|
const POKE = ANamespace::ZOT . '/activity/poke';
|
2019-10-23 22:25:43 +00:00
|
|
|
|
2019-10-24 07:06:22 +00:00
|
|
|
const OBJ_BOOKMARK = ANamespace::ACTIVITY_SCHEMA . 'bookmark';
|
|
|
|
const OBJ_COMMENT = ANamespace::ACTIVITY_SCHEMA . 'comment';
|
|
|
|
const OBJ_NOTE = ANamespace::ACTIVITY_SCHEMA . 'note';
|
|
|
|
const OBJ_PERSON = ANamespace::ACTIVITY_SCHEMA . 'person';
|
|
|
|
const OBJ_IMAGE = ANamespace::ACTIVITY_SCHEMA . 'image';
|
|
|
|
const OBJ_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'photo';
|
|
|
|
const OBJ_VIDEO = ANamespace::ACTIVITY_SCHEMA . 'video';
|
|
|
|
const OBJ_P_PHOTO = ANamespace::ACTIVITY_SCHEMA . 'profile-photo';
|
|
|
|
const OBJ_ALBUM = ANamespace::ACTIVITY_SCHEMA . 'photo-album';
|
|
|
|
const OBJ_EVENT = ANamespace::ACTIVITY_SCHEMA . 'event';
|
|
|
|
const OBJ_GROUP = ANamespace::ACTIVITY_SCHEMA . 'group';
|
|
|
|
const OBJ_TAGTERM = ANamespace::DFRN . '/tagterm';
|
|
|
|
const OBJ_PROFILE = ANamespace::DFRN . '/profile';
|
2019-10-23 22:25:43 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-10-23 00:05:11 +00:00
|
|
|
/**
|
|
|
|
* Compare activity uri. Knows about activity namespace.
|
|
|
|
*
|
|
|
|
* @param string $haystack
|
|
|
|
* @param string $needle
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2019-10-23 22:25:43 +00:00
|
|
|
public function match(string $haystack, string $needle)
|
|
|
|
{
|
2019-10-23 00:05:11 +00:00
|
|
|
return (($haystack === $needle) ||
|
|
|
|
((basename($needle) === $haystack) &&
|
2019-10-24 07:06:22 +00:00
|
|
|
strstr($needle, ANamespace::ACTIVITY_SCHEMA)));
|
2019-10-23 00:05:11 +00:00
|
|
|
}
|
|
|
|
}
|