aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/activities.php25
-rw-r--r--include/api_zot.php2
-rw-r--r--include/attach.php165
-rw-r--r--include/channel.php3
-rw-r--r--include/conversation.php170
-rw-r--r--include/event.php4
-rw-r--r--include/feedutils.php40
-rw-r--r--include/items.php91
-rw-r--r--include/photos.php6
-rw-r--r--include/sharedwithme.php32
-rw-r--r--include/text.php6
11 files changed, 67 insertions, 477 deletions
diff --git a/include/activities.php b/include/activities.php
index 68c995338..f5f0e55da 100644
--- a/include/activities.php
+++ b/include/activities.php
@@ -2,6 +2,11 @@
function profile_activity($changed, $value) {
+ // TODO: we should probably send an Update/Profile or Person activity here.
+ // We could also just send a Note with some changed info?
+ // Profiles are currently a hubzilla specific thing.
+ return;
+
if(! local_channel() || ! is_array($changed) || ! count($changed))
return;
@@ -26,10 +31,10 @@ function profile_activity($changed, $value) {
$arr['item_origin'] = 1;
$arr['item_thread_top'] = 1;
$arr['verb'] = ACTIVITY_UPDATE;
- $arr['obj_type'] = ACTIVITY_OBJ_PROFILE;
+ $arr['obj_type'] = 'Profile';
$arr['plink'] = z_root() . '/channel/' . $self['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']);
-
+
$A = '[url=' . z_root() . '/channel/' . $self['channel_address'] . ']' . $self['channel_name'] . '[/url]';
@@ -47,7 +52,7 @@ function profile_activity($changed, $value) {
$changes .= $ch;
}
- $prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]';
+ $prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]';
if($t == 1 && strlen($value)) {
// if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to.
@@ -61,24 +66,24 @@ function profile_activity($changed, $value) {
}
else
$message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
-
- $arr['body'] = $message;
+
+ $arr['body'] = $message;
$links = array();
- $links[] = array('rel' => 'alternate', 'type' => 'text/html',
+ $links[] = array('rel' => 'alternate', 'type' => 'text/html',
'href' => z_root() . '/profile/' . $self['channel_address']);
- $links[] = array('rel' => 'photo', 'type' => $self['xchan_photo_mimetype'],
- 'href' => $self['xchan_photo_l']);
+ $links[] = array('rel' => 'photo', 'type' => $self['xchan_photo_mimetype'],
+ 'href' => $self['xchan_photo_l']);
$arr['object'] = json_encode(array(
- 'type' => ACTIVITY_OBJ_PROFILE,
+ 'type' => 'Profile',
'title' => $self['channel_name'],
'id' => $self['xchan_url'] . '/' . $self['xchan_hash'],
'link' => $links
));
-
+
$arr['allow_cid'] = $self['channel_allow_cid'];
$arr['allow_gid'] = $self['channel_allow_gid'];
$arr['deny_cid'] = $self['channel_deny_cid'];
diff --git a/include/api_zot.php b/include/api_zot.php
index 7a217854f..22692b962 100644
--- a/include/api_zot.php
+++ b/include/api_zot.php
@@ -561,7 +561,7 @@
$mod = new Zotlabs\Module\Wall_attach();
$media = $mod->post();
if($media)
- $_REQUEST['body'] .= "\n\n" . $media;
+ $_REQUEST['body'] = $media . "\n\n" . $_REQUEST['body'];
}
$mod = new Zotlabs\Module\Item();
diff --git a/include/attach.php b/include/attach.php
index 8bbd73dde..e5a2900b3 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -1854,169 +1854,6 @@ function pipe_streams($in, $out, $bufsize = 16384) {
return $size;
}
-/**
- * @brief Activity for files.
- *
- * @param int $channel_id
- * @param array $object
- * @param string $allow_cid
- * @param string $allow_gid
- * @param string $deny_cid
- * @param string $deny_gid
- * @param string $verb
- * @param boolean $notify
- */
-/*
-function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify) {
-
- require_once('include/items.php');
-
- $poster = App::get_observer();
-
- //if we got no object something went wrong
- if(!$object)
- return;
-
- //turn strings into arrays
- $arr_allow_cid = expand_acl($allow_cid);
- $arr_allow_gid = expand_acl($allow_gid);
- $arr_deny_cid = expand_acl($deny_cid);
- $arr_deny_gid = expand_acl($deny_gid);
-
- //filter out receivers which do not have permission to view filestorage
- $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage');
-
- $is_dir = (intval($object['is_dir']) ? true : false);
-
- //do not send activity for folders for now
- if($is_dir)
- return;
-
- //check for recursive perms if we are in a folder
- if($object['folder']) {
-
- $folder_hash = $object['folder'];
-
- $r_perms = attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash);
-
- if($r_perms === false) //nobody has recursive perms - nobody must be notified
- return;
-
- //split up returned perms
- $arr_allow_cid = $r_perms['allow_cid'];
- $arr_allow_gid = $r_perms['allow_gid'];
- $arr_deny_cid = $r_perms['deny_cid'];
- $arr_deny_gid = $r_perms['deny_gid'];
-
- //filter out receivers which do not have permission to view filestorage
- $arr_allow_cid = check_list_permissions($channel_id, $arr_allow_cid, 'view_storage');
- }
-
- $uuid = item_message_id();
- $mid = z_root() . '/item/' . $uuid;
-
- $objtype = 'ACTIVITY_OBJ_FILE';
-
- $arr = array();
- $arr['aid'] = get_account_id();
- $arr['uid'] = $channel_id;
- $arr['uuid'] = $uuid;
- $arr['item_wall'] = 1;
- $arr['item_origin'] = 1;
- $arr['item_unseen'] = 1;
- $arr['author_xchan'] = $poster['xchan_hash'];
- $arr['owner_xchan'] = $poster['xchan_hash'];
- $arr['title'] = '';
- $arr['item_notshown'] = 1;
- $arr['obj_type'] = $objtype;
- $arr['resource_id'] = $object['hash'];
- $arr['resource_type'] = 'attach';
-
- $private = (($arr_allow_cid[0] || $arr_allow_gid[0] || $arr_deny_cid[0] || $arr_deny_gid[0]) ? 1 : 0);
-
- $jsonobject = json_encode($object);
-
- //check if item for this object exists
- $y = q("SELECT mid FROM item WHERE verb = '%s' AND obj_type = '%s' AND resource_id = '%s' AND uid = %d LIMIT 1",
- dbesc(ACTIVITY_POST),
- dbesc($objtype),
- dbesc($object['hash']),
- intval(local_channel())
- );
-
- if($y) {
- $update = true;
- $object['d_mid'] = $y[0]['mid']; //attach mid of the old object
- $u_jsonobject = json_encode($object);
-
- //we have got the relevant info - delete the old item before we create the new one
- q("DELETE FROM item WHERE obj_type = '%s' AND verb = '%s' AND mid = '%s'",
- dbesc(ACTIVITY_OBJ_FILE),
- dbesc(ACTIVITY_POST),
- dbesc($y[0]['mid'])
- );
-
- }
-
- //send update activity and create a new one
- if($update && $verb == 'post' ) {
- //updates should be sent to everybody with recursive perms and all eventual former allowed members ($object['allow_cid'] etc.).
- $u_arr_allow_cid = array_unique(array_merge($arr_allow_cid, expand_acl($object['allow_cid'])));
- $u_arr_allow_gid = array_unique(array_merge($arr_allow_gid, expand_acl($object['allow_gid'])));
- $u_arr_deny_cid = array_unique(array_merge($arr_deny_cid, expand_acl($object['deny_cid'])));
- $u_arr_deny_gid = array_unique(array_merge($arr_deny_gid, expand_acl($object['deny_gid'])));
-
- $private = (($u_arr_allow_cid[0] || $u_arr_allow_gid[0] || $u_arr_deny_cid[0] || $u_arr_deny_gid[0]) ? 1 : 0);
-
- $uuid = item_message_id();
- $u_mid = z_root() . '/item/' . $uuid;
-
- $arr['uuid'] = $uuid;
- $arr['mid'] = $u_mid;
- $arr['parent_mid'] = $u_mid;
- $arr['allow_cid'] = perms2str($u_arr_allow_cid);
- $arr['allow_gid'] = perms2str($u_arr_allow_gid);
- $arr['deny_cid'] = perms2str($u_arr_deny_cid);
- $arr['deny_gid'] = perms2str($u_arr_deny_gid);
- $arr['item_private'] = $private;
- $arr['verb'] = ACTIVITY_UPDATE;
- $arr['obj'] = $u_jsonobject;
- $arr['body'] = '';
-
- post_activity_item($arr);
-
- $update = false;
- }
-
- //don't create new activity if notify was not enabled
- if(! $notify) {
- return;
- }
-
- //don't create new activity if we have an update request but there is no item to update
- //this can e.g. happen when deleting images
- if(! $y && $verb == 'update') {
- return;
- }
-
- $arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
- $arr['allow_cid'] = perms2str($arr_allow_cid);
- $arr['allow_gid'] = perms2str($arr_allow_gid);
- $arr['deny_cid'] = perms2str($arr_deny_cid);
- $arr['deny_gid'] = perms2str($arr_deny_gid);
- $arr['item_private'] = $private;
- $arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST);
- $arr['obj'] = (($update) ? $u_jsonobject : $jsonobject);
- $arr['body'] = '';
-
- post_activity_item($arr);
-
- return;
-}
-*/
-
-
function attach_store_item($channel, $observer, $file) {
@@ -2127,7 +1964,7 @@ function attach_store_item($channel, $observer, $file) {
$arr['item_origin'] = 1;
$arr['item_thread_top'] = 1;
$arr['item_private'] = (($file['allow_cid'] || $file['allow_gid'] || $file['deny_cid'] || $file['deny_gid']) ? 1 : 0);
- $arr['verb'] = ACTIVITY_CREATE;
+ $arr['verb'] = 'Create';
$arr['obj_type'] = $type;
$arr['title'] = $file['filename'];
diff --git a/include/channel.php b/include/channel.php
index 8045ea333..b8affa3ca 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1777,11 +1777,12 @@ function advanced_profile() {
$profile['profile_guid'] = App::$profile['profile_guid'];
}
- $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'",
+ $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and (target_type = 'Profile' OR target_type = '%s') and (verb = 'Like' OR verb = '%s')",
intval(App::$profile['profile_uid']),
dbesc(ACTIVITY_OBJ_PROFILE),
dbesc(ACTIVITY_LIKE)
);
+
$profile['likers'] = array();
$profile['like_count'] = count($likers);
$profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun');
diff --git a/include/conversation.php b/include/conversation.php
index c04e32999..7074e1c36 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -90,7 +90,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
function localize_item(&$item){
- if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE) || activity_match($item['verb'],ACTIVITY_SHARE)){
+ if (activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE])){
if(! $item['obj'])
return;
@@ -143,7 +143,7 @@ function localize_item(&$item){
switch($obj['type']) {
case ACTIVITY_OBJ_PHOTO:
- case 'Photo':
+ case 'Image':
$post_type = t('photo');
break;
case ACTIVITY_OBJ_EVENT:
@@ -151,6 +151,7 @@ function localize_item(&$item){
$post_type = t('event');
break;
case ACTIVITY_OBJ_PERSON:
+ case 'Person':
$post_type = t('channel');
$author_name = $obj['title'];
if($obj['link']) {
@@ -189,26 +190,17 @@ function localize_item(&$item){
$plink = '[zrl=' . zid($item_url) . ']' . $post_type . '[/zrl]';
- if(activity_match($item['verb'],ACTIVITY_LIKE)) {
+ if(activity_match($item['verb'], ['Like', ACTIVITY_LIKE])) {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
- }
- elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
- $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- }
- elseif(activity_match($item['verb'],ACTIVITY_SHARE)) {
- $bodyverb = t('%1$s repeated %2$s\'s %3$s');
- }
-
-
- // short version, in notification strings the author will be displayed separately
-
- if(activity_match($item['verb'],ACTIVITY_LIKE)) {
+ // short version, in notification strings the author will be displayed separately
$shortbodyverb = t('likes %1$s\'s %2$s');
}
- elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
+ elseif(activity_match($item['verb'], ['Dislike', ACTIVITY_DISLIKE])) {
+ $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
$shortbodyverb = t('doesn\'t like %1$s\'s %2$s');
}
- elseif(activity_match($item['verb'],ACTIVITY_SHARE)) {
+ elseif(activity_match($item['verb'], ACTIVITY_SHARE)) {
+ $bodyverb = t('%1$s repeated %2$s\'s %3$s');
$shortbodyverb = t('repeated %1$s\'s %2$s');
}
@@ -225,9 +217,9 @@ function localize_item(&$item){
}
- if (activity_match($item['verb'],ACTIVITY_FRIEND)) {
+ if (activity_match($item['verb'], ACTIVITY_FRIEND)) {
- if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON)
+ if ($item['obj_type'] == "" || !in_array($item['obj_type'], ['Person', ACTIVITY_OBJ_PERSON]))
return;
$Aname = $item['author']['xchan_name'];
@@ -264,7 +256,8 @@ function localize_item(&$item){
if(! $verb)
return;
- if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
+ if ($item['obj_type']=="" || !in_array($item['obj_type'], ['Person', ACTIVITY_OBJ_PERSON]))
+ return;
$Aname = $item['author']['xchan_name'];
$Alink = $item['author']['xchan_url'];
@@ -314,102 +307,6 @@ function localize_item(&$item){
$item['body'] = sprintf($txt, $A, t($verb));
}
-
-
-/*
-// FIXME store parent item as object or target
-// (and update to json storage)
-
- if (activity_match($item['verb'],ACTIVITY_TAG)) {
- $r = q("SELECT * from item,contact WHERE
- item.contact-id=contact.id AND item.mid='%s';",
- dbesc($item['parent_mid']));
- if(count($r)==0) return;
- $obj=$r[0];
-
- $author = '[zrl=' . zid($item['author-link']) . ']' . $item['author-name'] . '[/zrl]';
- $objauthor = '[zrl=' . zid($obj['author-link']) . ']' . $obj['author-name'] . '[/zrl]';
-
- switch($obj['verb']){
- case ACTIVITY_POST:
- switch ($obj['obj_type']){
- case ACTIVITY_OBJ_EVENT:
- $post_type = t('event');
- break;
- default:
- $post_type = t('status');
- }
- break;
- default:
- if($obj['resource_id']){
- $post_type = t('photo');
- $m=array(); preg_match("/\[[zu]rl=([^]]*)\]/", $obj['body'], $m);
- $rr['plink'] = $m[1];
- } else {
- $post_type = t('status');
- }
- }
- $plink = '[zrl=' . $obj['plink'] . ']' . $post_type . '[/zrl]';
-
-// $parsedobj = parse_xml_string($xmlhead.$item['obj']);
-
- $tag = sprintf('#[zrl=%s]%s[/zrl]', $parsedobj->id, $parsedobj->content);
- $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag );
-
- }
-
- if (activity_match($item['verb'],ACTIVITY_FAVORITE)){
-
- if ($item['obj_type']== "")
- return;
-
- $Aname = $item['author']['xchan_name'];
- $Alink = $item['author']['xchan_url'];
-
- $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
-
-// $obj = parse_xml_string($xmlhead.$item['obj']);
- if(strlen($obj->id)) {
- $r = q("select * from item where mid = '%s' and uid = %d limit 1",
- dbesc($obj->id),
- intval($item['uid'])
- );
- if(count($r) && $r[0]['plink']) {
- $target = $r[0];
- $Bname = $target['author-name'];
- $Blink = $target['author-link'];
- $A = '[zrl=' . zid($Alink) . ']' . $Aname . '[/zrl]';
- $B = '[zrl=' . zid($Blink) . ']' . $Bname . '[/zrl]';
- $P = '[zrl=' . $target['plink'] . ']' . t('post/item') . '[/zrl]';
- $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
-
- }
- }
- }
-*/
-
-/*
- $matches = null;
- if(strpos($item['body'],'[zrl') !== false) {
- if(preg_match_all('/@\[zrl=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
- foreach($matches as $mtch) {
- if(! strpos($mtch[1],'zid='))
- $item['body'] = str_replace($mtch[0],'@[zrl=' . zid($mtch[1]). ']',$item['body']);
- }
- }
- }
-
- if(strpos($item['body'],'[zmg') !== false) {
- // add zid's to public images
- if(preg_match_all('/\[zrl=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[zmg(.*?)\]h(.*?)\[\/zmg\]\[\/zrl\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
- foreach($matches as $mtch) {
- $item['body'] = str_replace($mtch[0],'[zrl=' . zid( $mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3]) . '][zmg' . $mtch[4] . ']h' . $mtch[5] . '[/zmg][/zrl]',$item['body']);
- }
- }
- }
-*/
-
-
}
/**
@@ -448,7 +345,7 @@ function count_descendants($item) {
* @return boolean
*/
function visible_activity($item) {
- $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE ];
+ $hidden_activities = ['Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept', ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_SHARE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE];
if(intval($item['item_notshown']))
return false;
@@ -483,27 +380,6 @@ function visible_activity($item) {
return true;
}
-/**
- * @brief Check if a given activity is an edit activity
- *
- *
- * @param array $item
- * @return boolean
- */
-
-function is_edit_activity($item) {
-
- $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)];
-
- // In order to share edits with networks which have no concept of editing, we'll create
- // separate activities to indicate the edit. Our network will not require them, since our
- // edits are automatically applied and the activity indicated.
-
- if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types)))
- return true;
-
- return false;
-}
/**
* @brief "Render" a conversation or list of items for HTML display.
@@ -726,9 +602,9 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$is_new = false;
if($mode === 'search' || $mode === 'community') {
- if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
- && ($item['id'] != $item['parent']))
+ if(activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE]) && $item['id'] != $item['parent']) {
continue;
+ }
}
$sp = false;
@@ -1192,7 +1068,7 @@ function builtin_activity_puller($item, &$conv_responses) {
// if this item is a post or comment there's nothing for us to do here, just return.
- if(activity_match($item['verb'],ACTIVITY_POST) && $item['obj_type'] !== 'Answer')
+ if(activity_match($item['verb'], ['Create', ACTIVITY_POST]) && $item['obj_type'] !== 'Answer')
return;
foreach($conv_responses as $mode => $v) {
@@ -1201,10 +1077,10 @@ function builtin_activity_puller($item, &$conv_responses) {
switch($mode) {
case 'like':
- $verb = ACTIVITY_LIKE;
+ $verb = ['Like', ACTIVITY_LIKE];
break;
case 'dislike':
- $verb = ACTIVITY_DISLIKE;
+ $verb = ['Dislike', ACTIVITY_DISLIKE];
break;
case 'agree':
$verb = ACTIVITY_AGREE;
@@ -1216,16 +1092,16 @@ function builtin_activity_puller($item, &$conv_responses) {
$verb = ACTIVITY_ABSTAIN;
break;
case 'attendyes':
- $verb = ACTIVITY_ATTEND;
+ $verb = ['Accept', ACTIVITY_ATTEND];
break;
case 'attendno':
- $verb = ACTIVITY_ATTENDNO;
+ $verb = ['Reject', ACTIVITY_ATTENDNO];
break;
case 'attendmaybe':
- $verb = ACTIVITY_ATTENDMAYBE;
+ $verb = ['TentativeAccept', ACTIVITY_ATTENDMAYBE];
break;
case 'answer':
- $verb = ACTIVITY_POST;
+ $verb = ['Create', ACTIVITY_POST];
break;
case 'announce':
$verb = 'Announce';
diff --git a/include/event.php b/include/event.php
index dde5c405d..701f3c330 100644
--- a/include/event.php
+++ b/include/event.php
@@ -1311,7 +1311,7 @@ function event_store_item($arr, $event) {
dbesc($sig),
intval($r[0]['item_flags']),
intval($private),
- dbesc(ACTIVITY_OBJ_EVENT),
+ dbesc('Event'),
intval($r[0]['id']),
intval($arr['uid'])
);
@@ -1408,7 +1408,7 @@ function event_store_item($arr, $event) {
$item_arr['resource_type'] = 'event';
$item_arr['resource_id'] = $event['event_hash'];
- $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT;
+ $item_arr['obj_type'] = 'Event';
$item_arr['body'] = $prefix . format_event_bbcode($arr);
// if it's local send the permalink to the channel page.
diff --git a/include/feedutils.php b/include/feedutils.php
index a2d52c698..f05c15414 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -184,7 +184,7 @@ function construct_verb($item) {
if ($item['verb'])
return $item['verb'];
- return ACTIVITY_POST;
+ return 'Create';
}
function construct_activity_object($item) {
@@ -305,7 +305,7 @@ function get_atom_author($feed, $item) {
}
$rawactor = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor');
- if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ACTIVITY_OBJ_PERSON)) {
+ if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ['Person', ACTIVITY_OBJ_PERSON])) {
$base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
if($base && count($base)) {
foreach($base as $link) {
@@ -350,7 +350,7 @@ function get_atom_author($feed, $item) {
$rawactor = $feed->get_feed_tags(NAMESPACE_ACTIVITY, 'subject');
- if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'],ACTIVITY_OBJ_PERSON)) {
+ if($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ['Person', ACTIVITY_OBJ_PERSON])) {
$base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
if($base && count($base)) {
@@ -508,36 +508,17 @@ function get_atom_elements($feed, $item) {
}
}
- $ostatus_protocol = ($ostatus_conversation || (x($res,'verb') && $res['verb']) ? true : false);
-
$mastodon = (($item->get_item_tags('http://mastodon.social/schema/1.0','scope')) ? true : false);
if($mastodon) {
- $ostatus_protocol = true;
if(($mastodon[0]['data']) && ($mastodon[0]['data'] !== 'public'))
$res['item_private'] = 1;
}
- logger('ostatus_protocol: ' . intval($ostatus_protocol), LOGGER_DEBUG);
-
$apps = $item->get_item_tags(NAMESPACE_STATUSNET, 'notice_info');
if($apps && $apps[0]['attribs']['']['source']) {
$res['app'] = strip_tags(unxmlify($apps[0]['attribs']['']['source']));
}
- if($ostatus_protocol) {
-
- // translate OStatus unfollow to activity streams if it happened to get selected
-
- if((x($res,'verb')) && ($res['verb'] === 'http://ostatus.org/schema/1.0/unfollow')) {
- $res['verb'] = ACTIVITY_UNFOLLOW;
- }
-
- // And OStatus 'favorite' is pretty much what we call 'like' on other networks
-
- if((x($res,'verb')) && ($res['verb'] === ACTIVITY_FAVORITE)) {
- $res['verb'] = ACTIVITY_LIKE;
- }
- }
/*
* If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it.
@@ -600,10 +581,7 @@ function get_atom_elements($feed, $item) {
$terms = [];
- if($ostatus_protocol) {
- $res['title'] = '';
- }
- elseif($res['plink'] && $res['title']) {
+ if($res['plink'] && $res['title']) {
$res['body'] = '#^[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body'];
$terms[] = array(
'otype' => TERM_OBJ_POST,
@@ -814,7 +792,7 @@ function get_atom_elements($feed, $item) {
if(array_key_exists('verb',$res) && $res['verb'] === ACTIVITY_SHARE
- && array_key_exists('obj_type',$res) && in_array($res['obj_type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, ACTIVITY_OBJ_ACTIVITY ] )) {
+ && array_key_exists('obj_type',$res) && in_array($res['obj_type'], ['Note', ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT])) {
feed_get_reshare($res,$item);
}
@@ -1197,7 +1175,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
// Update content if 'updated' changes
if($r) {
- if(activity_match($datarray['verb'],ACTIVITY_DELETE)
+ if(activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE])
&& $datarray['author_xchan'] === $r[0]['author_xchan']) {
if(! intval($r[0]['item_deleted'])) {
logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG);
@@ -1361,7 +1339,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
// allow likes of comments
- if($item_parent_mid && activity_match($datarray['verb'],ACTIVITY_LIKE)) {
+ if($item_parent_mid && activity_match($datarray['verb'], ['Like', ACTIVITY_LIKE])) {
$datarray['thr_parent'] = $item_parent_mid[0]['parent_mid'];
}
@@ -1465,7 +1443,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
// Update content if 'updated' changes
if($r) {
- if(isset($datarray['verb']) && activity_match($datarray['verb'], ACTIVITY_DELETE)
+ if(isset($datarray['verb']) && activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE])
&& isset($datarray['author_xchan']) && $datarray['author_xchan'] === $r[0]['author_xchan']) {
if(! intval($r[0]['item_deleted'])) {
logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG);
@@ -1955,7 +1933,7 @@ function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0, $
$o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n";
}
- if(activity_match($item['obj_type'],ACTIVITY_OBJ_EVENT) && activity_match($item['verb'],ACTIVITY_POST)) {
+ if((activity_match($item['obj_type'], ACTIVITY_OBJ_EVENT) || activity_match($item['obj_type'], 'Event')) && activity_match($item['verb'],['Create', ACTIVITY_POST])) {
$obj = ((is_array($item['obj'])) ? $item['obj'] : json_decode($item['obj'],true));
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
diff --git a/include/items.php b/include/items.php
index f30a986bb..f689cc7b5 100644
--- a/include/items.php
+++ b/include/items.php
@@ -468,10 +468,8 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
$arr['owner_xchan'] = ((x($arr,'owner_xchan')) ? $arr['owner_xchan'] : $channel['channel_hash']);
$arr['author_xchan'] = ((x($arr,'author_xchan')) ? $arr['author_xchan'] : $observer['xchan_hash']);
- $arr['verb'] = ((x($arr,'verb')) ? $arr['verb'] : ACTIVITY_POST);
- $arr['obj_type'] = ((x($arr,'obj_type')) ? $arr['obj_type'] : ACTIVITY_OBJ_NOTE);
- if(($is_comment) && ($arr['obj_type'] === ACTIVITY_OBJ_NOTE))
- $arr['obj_type'] = ACTIVITY_OBJ_COMMENT;
+ $arr['verb'] = ((x($arr,'verb')) ? $arr['verb'] : 'Create');
+ $arr['obj_type'] = ((x($arr,'obj_type')) ? $arr['obj_type'] : 'Note');
if(! ( array_key_exists('allow_cid',$arr) || array_key_exists('allow_gid',$arr)
|| array_key_exists('deny_cid',$arr) || array_key_exists('deny_gid',$arr))) {
@@ -1751,8 +1749,8 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');
$arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : '');
$arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']);
- $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ACTIVITY_POST);
- $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ACTIVITY_OBJ_NOTE);
+ $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : 'Create');
+ $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : 'Note');
$arr['obj'] = ((x($arr,'obj')) ? trim($arr['obj']) : '');
$arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : '');
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : '');
@@ -1827,9 +1825,6 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
return $ret;
}
- if(($arr['obj_type'] == ACTIVITY_OBJ_NOTE) && (! $arr['obj']))
- $arr['obj_type'] = ACTIVITY_OBJ_COMMENT;
-
// is the new message multi-level threaded?
// even though we don't support it now, preserve the info
// and re-attach to the conversation parent.
@@ -2448,7 +2443,7 @@ function send_status_notifications($post_id,$item) {
$type = ((intval($item['item_private']) === 2) ? NOTIFY_MAIL : NOTIFY_COMMENT);
- if(array_key_exists('verb',$item) && (activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE))) {
+ if(array_key_exists('verb',$item) && activity_match($item['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
$type = NOTIFY_LIKE;
@@ -2493,7 +2488,7 @@ function send_status_notifications($post_id,$item) {
// but it will be extremely rare for this to be wrong.
if(($xx['verb'] === ACTIVITY_UNFOLLOW)
- && ($xx['obj_type'] === ACTIVITY_OBJ_NOTE || $xx['obj_type'] === ACTIVITY_OBJ_PHOTO)
+ && (in_array($xx['obj_type'], ['Note', 'Image', ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_PHOTO]))
&& ($xx['parent'] != $xx['id']))
$unfollowed = true;
}
@@ -2636,7 +2631,7 @@ function tag_deliver($uid, $item_id) {
if (stristr($item['verb'],ACTIVITY_POKE)) {
$poke_notify = true;
- if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['obj']))
+ if(($item['obj_type'] == "") || (!in_array($item['obj_type'], ['Person', ACTIVITY_OBJ_PERSON])) || (! $item['obj']))
$poke_notify = false;
$obj = json_decode($item['obj'],true);
@@ -3302,7 +3297,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false
$arr['owner_xchan'] = $channel['channel_hash'];
$arr['obj_type'] = $item['obj_type'];
- $arr['verb'] = ACTIVITY_POST;
+ $arr['verb'] = 'Create';
$arr['allow_cid'] = $channel['channel_allow_cid'];
$arr['allow_gid'] = $channel['channel_allow_gid'];
@@ -5156,83 +5151,13 @@ function fix_attached_permissions($uid, $body, $str_contact_allow, $str_group_al
}
}
-function item_create_edit_activity($post) {
-
- if((! $post) || (! $post['item']) || ($post['item']['item_type'] != ITEM_TYPE_POST))
- return;
-
- $update_item = $post['item'];
-
- $new_item = $update_item;
-
- $author = q("select * from xchan where xchan_hash = '%s' limit 1",
- dbesc($new_item['author_xchan'])
- );
- if($author)
- $item_author = $author[0];
-
-
- $new_item['id'] = 0;
- $new_item['parent'] = 0;
- $new_item['uuid'] = item_message_id();
- $new_item['mid'] = z_root() . '/item/' . $new_item['uuid'];
-
- $new_item['body'] = sprintf( t('[Edited %s]'), (($update_item['item_thread_top']) ? t('Post','edit_activity') : t('Comment','edit_activity')));
-
- $new_item['body'] .= "\n\n";
- $new_item['body'] .= $update_item['body'];
-
- $new_item['sig'] = '';
-
- $new_item['verb'] = ACTIVITY_UPDATE;
- $new_item['item_thread_top'] = 0;
- $new_item['created'] = $new_item['edited'] = datetime_convert();
- $new_item['obj_type'] = (($update_item['item_thread_top']) ? ACTIVITY_OBJ_NOTE : ACTIVITY_OBJ_COMMENT);
- $new_item['obj'] = json_encode(array(
- 'type' => $new_item['obj_type'],
- 'id' => $update_item['mid'],
- 'parent' => $update_item['parent_mid'],
- 'link' => array(array('rel' => 'alternate','type' => 'text/html', 'href' => $update_item['plink'])),
- 'title' => $update_item['title'],
- 'content' => $update_item['body'],
- 'created' => $update_item['created'],
- 'edited' => $update_item['edited'],
- 'author' => array(
- 'name' => $item_author['xchan_name'],
- 'address' => $item_author['xchan_addr'],
- 'guid' => $item_author['xchan_guid'],
- 'guid_sig' => $item_author['xchan_guid_sig'],
- 'link' => array(
- array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item_author['xchan_url']),
- array('rel' => 'photo', 'type' => $item_author['xchan_photo_mimetype'], 'href' => $item_author['xchan_photo_m'])),
- ),
- ));
-
- $x = post_activity_item($new_item);
-
- $post_id = $x['id'];
- if($post_id) {
- $r = q("select * from item where id = %d",
- intval($post_id)
- );
- if($r) {
- xchan_query($r);
- $sync_item = fetch_post_tags($r);
- Libsync::build_sync_packet($new_item['uid'],array('item' => array(encode_item($sync_item[0],true))));
- }
- }
-
- Master::Summon([ 'Notifier', 'edit_activity', $post_id ]);
-}
/**
* @brief copies an entire conversation from the pubstream to this channel's stream
* which will allow you to interact with it.
*/
-
-
function copy_of_pubitem($channel,$mid) {
$result = null;
diff --git a/include/photos.php b/include/photos.php
index 8d83b8475..5e993e15f 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -455,7 +455,7 @@ function photo_upload($channel, $observer, $args) {
$item['body'] = $summary;
$item['mimetype'] = 'text/bbcode';
- $item['obj_type'] = ACTIVITY_OBJ_PHOTO;
+ $item['obj_type'] = 'Image';
$object['id'] = $item['mid'];
$object['diaspora:guid'] = $item['uuid'];
@@ -511,8 +511,8 @@ function photo_upload($channel, $observer, $args) {
'allow_gid' => $ac['allow_gid'],
'deny_cid' => $ac['deny_cid'],
'deny_gid' => $ac['deny_gid'],
- 'verb' => ACTIVITY_POST,
- 'obj_type' => ACTIVITY_OBJ_PHOTO,
+ 'verb' => 'Create',
+ 'obj_type' => 'Image',
'obj' => json_encode($object),
'tgt_type' => 'orderedCollection',
'target' => json_encode($target),
diff --git a/include/sharedwithme.php b/include/sharedwithme.php
deleted file mode 100644
index b342f51d5..000000000
--- a/include/sharedwithme.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-function apply_updates() {
-
- //check for updated items and remove them
- $x = q("SELECT mid, max(obj) AS obj FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid",
- dbesc(ACTIVITY_UPDATE),
- dbesc(ACTIVITY_OBJ_FILE)
- );
-
- if($x) {
-
- foreach($x as $xx) {
-
- $object = json_decode($xx['obj'],true);
-
- $d_mid = $object['d_mid'];
- $u_mid = $xx['mid'];
-
- $y = q("DELETE FROM item WHERE obj_type = '%s' AND (verb = '%s' AND mid = '%s') OR (verb = '%s' AND mid = '%s')",
- dbesc(ACTIVITY_OBJ_FILE),
- dbesc(ACTIVITY_POST),
- dbesc($d_mid),
- dbesc(ACTIVITY_UPDATE),
- dbesc($u_mid)
- );
-
- }
-
- }
-
-}
diff --git a/include/text.php b/include/text.php
index 052c26594..ea9cf45e1 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1776,7 +1776,7 @@ function prepare_body(&$item,$attach = false,$opts = false) {
$s = '';
$photo = '';
- $is_photo = ((($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) ? true : false);
+ $is_photo = (((in_array($item['verb'], ['Create', ACTIVITY_POST])) && (in_array($item['obj_type'], ['Image', ACTIVITY_OBJ_PHOTO]))) ? true : false);
if ($is_photo) {
$object = json_decode($item['obj'],true);
@@ -1821,7 +1821,7 @@ function prepare_body(&$item,$attach = false,$opts = false) {
}
- $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ ACTIVITY_POST, ACTIVITY_UPDATE, ACTIVITY_SHARE ])) ? format_poll($item, $s, $opts) : false);
+ $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],['Create', ACTIVITY_POST, ACTIVITY_UPDATE, ACTIVITY_SHARE])) ? format_poll($item, $s, $opts) : false);
if ($poll) {
$s = $poll;
}
@@ -2120,7 +2120,7 @@ function prepare_text($text, $content_type = 'text/bbcode', $opts = false) {
function create_export_photo_body(&$item) {
- if(($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) {
+ if((in_array($item['verb'], ['Create', ACTIVITY_POST])) && (in_array($item['obj_type'], ['Image', ACTIVITY_OBJ_PHOTO]))) {
$j = json_decode($item['obj'],true);
if($j) {
$item['body'] .= "\n\n" . (($j['body']) ? $j['body'] : $j['bbcode']);