Commit 7639157a authored by Mario's avatar Mario
Browse files

restrict returned html usage to local_channel() until some issues will be worked out

parent f74cfaec
Pipeline #365023 passed with stage
in 3 minutes and 41 seconds
......@@ -1374,16 +1374,24 @@ class Item extends Controller {
goaway(z_root() . "/" . $return_path);
}
$item[] = $datarray;
$item[0]['owner'] = $owner_xchan;
$item[0]['author'] = $observer;
$item[0]['attach'] = json_encode($datarray['attach']);
$json = [
'success' => 1,
'id' => $post_id,
'html' => conversation($item,'network',true,'r_preview'),
];
if(local_channel()) {
$item[] = $datarray;
$item[0]['owner'] = $owner_xchan;
$item[0]['author'] = $observer;
$item[0]['attach'] = json_encode($datarray['attach']);
$json = [
'success' => 1,
'id' => $post_id,
'html' => conversation($item,'network',true,'r_preview'),
];
}
else {
$json = [
'success' => 1
];
}
if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
$json['reload'] = z_root() . '/' . $_REQUEST['jsreload'];
......
......@@ -368,31 +368,33 @@ class Like extends \Zotlabs\Web\Controller {
return;
if(! $multi_undo) {
$item_normal = item_normal();
$activities = q("SELECT item.*, item.id AS item_id FROM item
WHERE uid = %d $item_normal
AND thr_parent = '%s'
AND verb IN ('%s', '%s', '%s', '%s', '%s')",
intval($owner_uid),
dbesc($item['mid']),
dbesc(ACTIVITY_LIKE),
dbesc(ACTIVITY_DISLIKE),
dbesc(ACTIVITY_ATTEND),
dbesc(ACTIVITY_ATTENDNO),
dbesc(ACTIVITY_ATTENDMAYBE)
);
xchan_query($activities,true);
$convitems[] = $item;
$convitems = array_merge($convitems, $activities);
$json = [
'success' => 1,
'orig_id' => $item_id,
'id' => $item['id'],
'html' => conversation($convitems,'network',true,'r_preview'),
];
echo json_encode($json);
if(local_channel()) {
$item_normal = item_normal();
$activities = q("SELECT item.*, item.id AS item_id FROM item
WHERE uid = %d $item_normal
AND thr_parent = '%s'
AND verb IN ('%s', '%s', '%s', '%s', '%s')",
intval($owner_uid),
dbesc($item['mid']),
dbesc(ACTIVITY_LIKE),
dbesc(ACTIVITY_DISLIKE),
dbesc(ACTIVITY_ATTEND),
dbesc(ACTIVITY_ATTENDNO),
dbesc(ACTIVITY_ATTENDMAYBE)
);
xchan_query($activities,true);
$convitems[] = $item;
$convitems = array_merge($convitems, $activities);
$json = [
'success' => 1,
'orig_id' => $item_id,
'id' => $item['id'],
'html' => conversation($convitems,'network',true,'r_preview'),
];
echo json_encode($json);
}
killme();
}
......@@ -531,33 +533,34 @@ class Like extends \Zotlabs\Web\Controller {
call_hooks('post_local',$arr);
$post = item_store($arr);
$post_id = $post['item_id'];
$item_normal = item_normal();
$activities = q("SELECT item.*, item.id AS item_id FROM item
WHERE uid = %d $item_normal
AND thr_parent = '%s'
AND verb IN ('%s', '%s', '%s', '%s', '%s')",
intval($owner_uid),
dbesc($item['mid']),
dbesc(ACTIVITY_LIKE),
dbesc(ACTIVITY_DISLIKE),
dbesc(ACTIVITY_ATTEND),
dbesc(ACTIVITY_ATTENDNO),
dbesc(ACTIVITY_ATTENDMAYBE)
);
xchan_query($activities,true);
$convitems[] = $item;
$convitems = array_merge($convitems, $activities);
$json = [
'success' => 1,
'orig_id' => $item_id, //this is required for pubstream where $item_id != $item['id']
'id' => $item['id'],
'html' => conversation($convitems,'network',true,'r_preview'),
];
if(local_channel()) {
$item_normal = item_normal();
$activities = q("SELECT item.*, item.id AS item_id FROM item
WHERE uid = %d $item_normal
AND thr_parent = '%s'
AND verb IN ('%s', '%s', '%s', '%s', '%s')",
intval($owner_uid),
dbesc($item['mid']),
dbesc(ACTIVITY_LIKE),
dbesc(ACTIVITY_DISLIKE),
dbesc(ACTIVITY_ATTEND),
dbesc(ACTIVITY_ATTENDNO),
dbesc(ACTIVITY_ATTENDMAYBE)
);
xchan_query($activities,true);
$convitems[] = $item;
$convitems = array_merge($convitems, $activities);
$json = [
'success' => 1,
'orig_id' => $item_id, //this is required for pubstream where $item_id != $item['id']
'id' => $item['id'],
'html' => conversation($convitems,'network',true,'r_preview'),
];
}
// save the conversation from expiration
......
......@@ -1148,24 +1148,30 @@ function justifyPhotosAjax(id) {
function dolike(ident, verb) {
$('#like-rotator-' + ident.toString()).show();
$.get('like/' + ident.toString() + '?verb=' + verb, function (data) {
data = JSON.parse(data);
if(data.success) {
// this is a bit tricky since the top level thread wrapper wraps the whole thread
if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) {
var wrapper = $('<div></div>').html( data.html ).find('#wall-item-outside-wrapper-' + data.id);
$('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML);
// those were not replaced - swap the id
$('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id);
$('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id);
}
else {
$('#thread-wrapper-' + data.orig_id).replaceWith(data.html);
if(! localUser) {
$.get('like/' + ident.toString() + '?verb=' + verb, updateInit);
}
else {
$.get('like/' + ident.toString() + '?verb=' + verb, function (data) {
data = JSON.parse(data);
if(data.success) {
// this is a bit tricky since the top level thread wrapper wraps the whole thread
if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) {
var wrapper = $('<div></div>').html( data.html ).find('#wall-item-outside-wrapper-' + data.id);
$('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML);
// those were not replaced - swap the id
$('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id);
$('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id);
}
else {
$('#thread-wrapper-' + data.orig_id).replaceWith(data.html);
}
$('#wall-item-ago-' + data.id + ' .autotime').timeago();
liking = 0;
}
$('#wall-item-ago-' + data.id + ' .autotime').timeago();
liking = 0;
}
});
});
}
liking = 1;
}
......@@ -1374,10 +1380,16 @@ function post_comment(id) {
localStorage.removeItem("comment_body-" + id);
$("#comment-edit-preview-" + id).hide();
$("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment);
$('#wall-item-comment-wrapper-' + id).before(data.html);
$('#wall-item-ago-' + data.id + ' .autotime').timeago();
$('body').css('cursor', 'unset');
commentBusy = false;
if(! localUser) {
updateInit();
}
else {
$('#wall-item-comment-wrapper-' + id).before(data.html);
$('#wall-item-ago-' + data.id + ' .autotime').timeago();
$('body').css('cursor', 'unset');
commentBusy = false;
}
var tarea = document.getElementById("comment-edit-text-" + id);
if(tarea) {
......
......@@ -14,7 +14,7 @@
var zid = {{if $zid}}'{{$zid}}'{{else}}null{{/if}};
var justifiedGalleryActive = false;
{{if $channel_hash}}var channelHash = '{{$channel_hash}}';{{/if}}
{{if $channel_id}}var channelId = '{{$channel_id}}';{{/if}}{{* Used in e.g. autocomplete *}}
var channelId = {{if $channel_id}}{{$channel_id}}{{else}}false{{/if}};{{* Used in e.g. autocomplete *}}
var preloadImages = {{$preload_images}};
var auto_save_draft = {{$auto_save_draft}};
</script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment