From 5e189cb14eb134eeb2e79fa5f909524f2a94e209 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Jun 2019 19:21:31 -0700 Subject: [PATCH] some early dev work for dm support --- Zotlabs/Lib/Activity.php | 11 ++++++ Zotlabs/Lib/Libzot.php | 4 +-- Zotlabs/Lib/ThreadItem.php | 4 +-- Zotlabs/Module/Apschema.php | 1 + Zotlabs/Module/Channel.php | 1 + Zotlabs/Module/Display.php | 1 + Zotlabs/Module/Hq.php | 1 + Zotlabs/Module/Item.php | 12 +++---- Zotlabs/Module/Lockview.php | 2 +- Zotlabs/Module/Network.php | 7 +++- Zotlabs/Module/Photos.php | 65 ++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Pubstream.php | 1 + Zotlabs/Module/Search.php | 1 + boot.php | 2 +- include/items.php | 22 +++++++----- view/tpl/build_query.tpl | 2 ++ 16 files changed, 116 insertions(+), 21 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 3048f0ba3..1810f4672 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -288,6 +288,10 @@ class Activity { $ret['commentPolicy'] = map_scope(PermissionLimits::Get($i['uid'],'post_comments')); } + if (intval($i['item_private']) === 2) { + $ret['directMessage'] = true; + } + if (array_key_exists('comments_closed',$i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] !== NULL_DATE) { if($ret['commentPolicy']) { $ret['commentPolicy'] .= ' '; @@ -1940,6 +1944,8 @@ class Activity { $s['item_deleted'] = 1; } + + $s['verb'] = self::activity_mapper($act->type); @@ -2178,6 +2184,11 @@ class Activity { if ($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) $s['item_private'] = 1; + + if (array_key_exists('directMessage',$act->obj)) { + $s['item_private'] = 2; + } + set_iconfig($s,'activitypub','recips',$act->raw_recips); if ($parent) { diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index d9b3a7768..4917e3a85 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1289,8 +1289,8 @@ class Libzot { $arr['owner_xchan'] = $env['sender']; } - if ($private) { - $arr['item_private'] = true; + if ($private && (! intval($arr['item_private']))) { + $arr['item_private'] = 1; } if ($arr['mid'] === $arr['parent_mid']) { if (is_array($AS->obj) && array_key_exists('commentPolicy',$AS->obj)) { diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index a1374ed05..0b41631c6 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -116,7 +116,7 @@ class ThreadItem { // logger('parent: ' . $item['thr_parent']); } - $lock = ((($item['item_private'] == 1) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) + $lock = (((intval($item['item_private'])) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? t('Private Message') : false); @@ -132,7 +132,7 @@ class ThreadItem { $privacy_warning = true; } - if(($item['item_private'] == 1) && ($item['owner']['xchan_network'] === 'activitypub')) { + if(intval($item['item_private']) && ($item['owner']['xchan_network'] === 'activitypub')) { $recips = get_iconfig($item['parent'], 'activitypub', 'recips'); diff --git a/Zotlabs/Module/Apschema.php b/Zotlabs/Module/Apschema.php index 996e0c0ee..8e0c6a10c 100644 --- a/Zotlabs/Module/Apschema.php +++ b/Zotlabs/Module/Apschema.php @@ -23,6 +23,7 @@ class Apschema extends \Zotlabs\Web\Controller { 'eventRepeat' => 'zot:eventRepeat', 'emojiReaction' => 'zot:emojiReaction', 'expires' => 'zot:expires', + 'directMessage' => 'zot:directMessage', ] ]; diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 217506582..b7c0895f1 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -440,6 +440,7 @@ class Channel extends Controller { '$nouveau' => '0', '$wall' => '1', '$fh' => '0', + '$dm' => '0', '$static' => $static, '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1), '$search' => $search, diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 120401952..c505970fc 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -224,6 +224,7 @@ class Display extends Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 6c7c09383..b70340060 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -178,6 +178,7 @@ class Hq extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 5940ab4e4..b3ae1b5b1 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -687,9 +687,9 @@ class Item extends Controller { $private = $orig_post['item_private']; } - if($private || $public_policy || $acl->is_private()) - $private = 1; - + if($public_policy || $acl->is_private()) { + $private = (($private) ? $private : 1); + } $location = $orig_post['location']; $coord = $orig_post['coord']; @@ -766,14 +766,14 @@ class Item extends Controller { $allow_empty = ((array_key_exists('allow_empty',$_REQUEST)) ? intval($_REQUEST['allow_empty']) : 0); - $private = intval($acl->is_private() || ($public_policy)); + $private = (($private) ? $private : intval($acl->is_private() || ($public_policy))); // If this is a comment, set the permissions from the parent. if($parent_item) { $private = 0; $acl->set($parent_item); - $private = intval($acl->is_private() || $parent_item['item_private']); + $private = ((intval($parent_item['item_private']) ? $parent_item['item_private'] : $acl->is_private())); $public_policy = $parent_item['public_policy']; $owner_hash = $parent_item['owner_xchan']; $webpage = $parent_item['item_type']; @@ -1105,7 +1105,7 @@ class Item extends Controller { $plink = z_root() . '/item/' . $uuid; } - + $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; $datarray['uuid'] = $uuid; diff --git a/Zotlabs/Module/Lockview.php b/Zotlabs/Module/Lockview.php index d7ed07a53..8c8519c57 100644 --- a/Zotlabs/Module/Lockview.php +++ b/Zotlabs/Module/Lockview.php @@ -76,7 +76,7 @@ class Lockview extends \Zotlabs\Web\Controller { killme(); } - if(($item['item_private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) + if(intval($item['item_private']) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) { // if the post is private, but public_policy is blank ("visible to the internet"), and there aren't any diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 0532b43dc..7413ca719 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -64,7 +64,7 @@ class Network extends Controller { $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); - + $dm = ((x($_REQUEST,'dm')) ? $_REQUEST['dm'] : 0); $order = get_pconfig(local_channel(), 'mod_network', 'order', 0); switch ($order) { @@ -336,6 +336,7 @@ class Network extends Controller { '$conv' => (($conv) ? $conv : '0'), '$spam' => (($spam) ? $spam : '0'), '$fh' => '0', + '$dm' => (($dm) ? $dm : '0'), '$nouveau' => (($nouveau) ? $nouveau : '0'), '$wall' => '0', '$static' => $static, @@ -399,6 +400,10 @@ class Network extends Controller { $sql_extra .= term_query('item',$file,TERM_FILE); } + if ($dm) { + $sql_extra .= " and item_private = 2 "; + } + if ($conv) { $item_thread_top = ''; diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 8b90cb27d..e5d2903c9 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -215,6 +215,71 @@ class Photos extends Controller { } } + // this still needs some work + + if(defined('FIXED')) { + if((x($_POST,'rotate') !== false) && ( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) { + logger('rotate'); + + $resource_id = argv(2); + + $r = q("select * from photo where resource_id = '%s' and uid = %d and imgscale = 0 limit 1", + dbesc($resource_id), + intval($page_owner_uid) + ); + if($r) { + + $ph = photo_factory(@file_get_contents(dbunescbin($r[0]['content'])), $r[0]['mimetype']); + if($ph->is_valid()) { + $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 ); + $ph->rotate($rotate_deg); + + $edited = datetime_convert(); + + q("update attach set filesize = %d, edited = '%s' where hash = '%s' and uid = %d", + strlen($ph->imageString()), + dbescdate($edited), + dbesc($resource_id), + intval($page_owner_uid) + ); + + $ph->saveImage(dbunescbin($r[0]['content'])); + + $arr = [ + 'aid' => get_account_id(), + 'uid' => intval($page_owner_uid), + 'resource_id' => dbesc($resource_id), + 'filename' => $r[0]['filename'], + 'imgscale' => 0, + 'album' => $r[0]['album'], + 'os_path' => $r[0]['os_path'], + 'os_storage' => 1, + 'os_syspath' => dbunescbin($r[0]['content']), + 'display_path' => $r[0]['display_path'], + 'photo_usage' => PHOTO_NORMAL, + 'edited' => dbescdate($edited) + ]; + + $ph->save($arr); + + unset($arr['os_syspath']); + + if($width > 1024 || $height > 1024) + $ph->scaleImage(1024); + $ph->storeThumbnail($arr, PHOTO_RES_1024); + + if($width > 640 || $height > 640) + $ph->scaleImage(640); + $ph->storeThumbnail($arr, PHOTO_RES_640); + + if($width > 320 || $height > 320) + $ph->scaleImage(320); + $ph->storeThumbnail($arr, PHOTO_RES_320); + } + } + }} + + if((argc() > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false))) { $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : ''); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 761dd6a35..026667dfe 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -125,6 +125,7 @@ class Pubstream extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '1', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$list' => '0', diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index e610481e3..6b2337ef2 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -131,6 +131,7 @@ class Search extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/boot.php b/boot.php index d9350b861..b86758eb1 100755 --- a/boot.php +++ b/boot.php @@ -466,7 +466,7 @@ define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' ); define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams' ); -define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.8' ); +define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.9' ); /** * activity stream defines */ diff --git a/include/items.php b/include/items.php index 0d1e8124c..93c7c7719 100644 --- a/include/items.php +++ b/include/items.php @@ -1842,10 +1842,13 @@ function item_store($arr, $allow_exec = false, $deliver = true, $linkid = true) } - if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) - $private = 1; - else - $private = $arr['item_private']; + $private = intval($arr['item_private']); + + if (! $private) { + if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) { + $private = 1; + } + } $arr['parent'] = $parent_id; $arr['allow_cid'] = $allow_cid; @@ -2881,9 +2884,12 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) $arr['item_uplink'] = 1; $arr['source_xchan'] = $item['owner_xchan']; - $arr['item_private'] = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] - || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0); + $arr['item_private'] = $item['item_private']; + if(! intval($arr['item_private'])) { + $arr['item_private'] = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] + || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0); + } $arr['item_origin'] = 1; $arr['item_wall'] = 1; @@ -4275,12 +4281,12 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow, if(strpos($access_tag,'cid:') === 0) { $str_contact_allow .= '<' . substr($access_tag,4) . '>'; $access_tag = ''; - $private = 1; + $private = 2; } elseif(strpos($access_tag,'gid:') === 0) { $str_group_allow .= '<' . substr($access_tag,4) . '>'; $access_tag = ''; - $private = 1; + $private = 2; } } } diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index 2c55a8140..01852500b 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -17,6 +17,7 @@ var bParam_wall = {{$wall}}; var bParam_list = {{$list}}; var bParam_fh = {{$fh}}; + var bParam_dm = {{$dm}}; var bParam_static = {{$static}}; var bParam_search = "{{$search}}"; @@ -49,6 +50,7 @@ if(bParam_wall != 0) bCmd = bCmd + "&wall=" + bParam_wall; if(bParam_list != 0) bCmd = bCmd + "&list=" + bParam_list; if(bParam_fh != 0) bCmd = bCmd + "&fh=" + bParam_fh; + if(bParam_dm != 0) bCmd = bCmd + "&dm=" + bParam_dm; if(bParam_search != "") bCmd = bCmd + "&search=" + bParam_search; if(bParam_xchan != "") bCmd = bCmd + "&xchan=" + bParam_xchan; if(bParam_order != "") bCmd = bCmd + "&order=" + bParam_order;