some early dev work for dm support

This commit is contained in:
zotlabs 2019-06-18 19:21:31 -07:00
parent 1d16263ece
commit 5e189cb14e
16 changed files with 116 additions and 21 deletions

View file

@ -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) {

View file

@ -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)) {

View file

@ -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');

View file

@ -23,6 +23,7 @@ class Apschema extends \Zotlabs\Web\Controller {
'eventRepeat' => 'zot:eventRepeat',
'emojiReaction' => 'zot:emojiReaction',
'expires' => 'zot:expires',
'directMessage' => 'zot:directMessage',
]
];

View file

@ -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,

View file

@ -224,6 +224,7 @@ class Display extends Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
'$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,

View file

@ -178,6 +178,7 @@ class Hq extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
'$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,

View file

@ -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;

View file

@ -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

View file

@ -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 = '';

View file

@ -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'])) : '');

View file

@ -125,6 +125,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '1',
'$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$list' => '0',

View file

@ -131,6 +131,7 @@ class Search extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
'$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,

View file

@ -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
*/

View file

@ -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;
}
}
}

View file

@ -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;