pubstream comments and a few other bugfixes that were discovered along the way

This commit is contained in:
zotlabs
2017-11-26 18:29:24 -08:00
parent e1fdac3278
commit 0e91810ed6
12 changed files with 206 additions and 79 deletions

View File

@@ -482,10 +482,10 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$previewing = (($preview) ? ' preview ' : '');
$preview_lbl = t('This is an unsaved preview');
if ($mode === 'network') {
if (in_array($mode, [ 'network', 'pubstream'])) {
$profile_owner = local_channel();
$page_writeable = true;
$page_writeable = ((local_channel()) ? true : false);
if (!$update) {
// The special div is needed for liveUpdate to kick in for this page.

View File

@@ -65,16 +65,35 @@ function get_feed_for($channel, $observer_hash, $params) {
if(! $channel)
http_status_exit(401);
if($params['pages']) {
if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_pages'))
http_status_exit(403);
} else {
if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream'))
http_status_exit(403);
}
// logger('params: ' . print_r($params,true));
$interactive = ((is_array($params) && array_key_exists('interactive',$params)) ? intval($params['interactive']) : 0);
if($params['pages']) {
if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_pages')) {
if($interactive) {
return '';
}
else {
http_status_exit(403);
}
}
}
else {
if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream')) {
if($interactive) {
return '';
}
else {
http_status_exit(403);
}
}
}
$feed_template = get_markup_template('atom_feed.tpl');
$atom = '';

View File

@@ -1749,22 +1749,6 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
intval($arr['uid'])
);
// perhaps the system channel owns the post and it's a pubstream item
if(! $r) {
$s = q("select channel_id from channel where channel_system = 1 limit 1");
if($s) {
$r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d ORDER BY id ASC LIMIT 1",
dbesc($arr['parent_mid']),
intval($s[0]['channel_id'])
);
}
if($r) {
$arr['uid'] = $r[0]['uid'];
$arr['aid'] = 0;
}
}
if($r) {
// in case item_store was killed before the parent's parent attribute got set,
@@ -4725,3 +4709,59 @@ function item_create_edit_activity($post) {
\Zotlabs\Daemon\Master::Summon(array('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;
$syschan = get_sys_channel();
// logger('copy_of_pubitem: ' . $channel['channel_id'] . ' mid: ' . $mid);
$r = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($mid),
intval($channel['channel_id'])
);
if($r) {
logger('exists');
$item = fetch_post_tags($r,true);
return $item[0];
}
$r = q("select * from item where parent_mid = (select parent_mid from item where mid = '%s' and uid = %d ) order by id ",
dbesc($mid),
intval($syschan['channel_id'])
);
if($r) {
$items = fetch_post_tags($r,true);
foreach($items as $rv) {
$d = q("select id from item where mid = '%s' and uid = %d limit 1",
dbesc($rv['mid']),
intval($channel['channel_id'])
);
if($d) {
continue;
}
unset($rv['id']);
unset($rv['parent']);
$rv['aid'] = $channel['channel_account_id'];
$rv['uid'] = $channel['channel_id'];
$x = item_store($rv);
if($x['item_id'] && $x['item']['mid'] === $mid) {
$result = $x['item'];
}
}
}
return $result;
}