Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hubzilla
core
Commits
c0adf31d
Commit
c0adf31d
authored
Nov 22, 2020
by
Mario
Browse files
fix like issue with remote channels
parent
bb43c57b
Pipeline
#365175
passed with stage
in 7 minutes and 17 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Zotlabs/Module/Channel.php
View file @
c0adf31d
...
...
@@ -390,7 +390,7 @@ class Channel extends Controller {
$o
.
=
'<div id="live-channel"></div>'
.
"
\r\n
"
;
$o
.
=
"<script> var profile_uid = "
.
App
::
$profile
[
'profile_uid'
]
.
"; var netargs = '?f='; var profile_page = "
.
App
::
$pager
[
'page'
]
.
"; divmore_height = "
.
intval
(
$maxheight
)
.
";
</script>
\r\n
"
;
.
"; divmore_height = "
.
intval
(
$maxheight
)
.
";</script>
\r\n
"
;
App
::
$page
[
'htmlhead'
]
.
=
replace_macros
(
get_markup_template
(
"build_query.tpl"
),
array
(
'$baseurl'
=>
z_root
(),
...
...
@@ -420,7 +420,8 @@ class Channel extends Controller {
'$verb'
=>
''
,
'$net'
=>
''
,
'$dend'
=>
$datequery
,
'$dbegin'
=>
$datequery2
'$dbegin'
=>
$datequery2
,
'$conv_mode'
=>
'channel'
));
}
...
...
Zotlabs/Module/Like.php
View file @
c0adf31d
...
...
@@ -66,7 +66,8 @@ class Like extends \Zotlabs\Web\Controller {
}
$verb
=
notags
(
trim
(
$_GET
[
'verb'
]));
$mode
=
((
$_GET
[
'conv_mode'
]
===
'channel'
)
?
'channel'
:
'network'
);
if
(
!
$verb
)
$verb
=
'like'
;
...
...
@@ -304,7 +305,7 @@ class Like extends \Zotlabs\Web\Controller {
$thread_owner
=
$r
[
0
];
else
killme
();
$r
=
q
(
"select * from xchan where xchan_hash = '%s' limit 1"
,
dbesc
(
$item
[
'author_xchan'
])
);
...
...
@@ -312,8 +313,7 @@ class Like extends \Zotlabs\Web\Controller {
$item_author
=
$r
[
0
];
else
killme
();
$verbs
=
" '"
.
dbesc
(
$activity
)
.
"' "
;
$multi_undo
=
false
;
...
...
@@ -368,33 +368,38 @@ class Like extends \Zotlabs\Web\Controller {
return
;
if
(
!
$multi_undo
)
{
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
);
}
if
(
$mode
===
'channel'
)
profile_load
(
$thread_owner
[
'xchan_name'
]);
$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
,
$mode
,
true
,
'r_preview'
),
];
echo
json_encode
(
$json
);
killme
();
}
...
...
@@ -536,31 +541,34 @@ class Like extends \Zotlabs\Web\Controller {
$post
=
item_store
(
$arr
);
$post_id
=
$post
[
'item_id'
];
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'
),
];
}
if
(
$mode
===
'channel'
)
profile_load
(
$thread_owner
[
'xchan_name'
]);
$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
,
$mode
,
true
,
'r_preview'
),
];
// save the conversation from expiration
...
...
@@ -597,7 +605,6 @@ class Like extends \Zotlabs\Web\Controller {
}
\
Zotlabs\Daemon\Master
::
Summon
(
array
(
'Notifier'
,
'like'
,
$post_id
));
if
(
$interactive
)
{
...
...
view/js/main.js
View file @
c0adf31d
...
...
@@ -1149,30 +1149,28 @@ function justifyPhotosAjax(id) {
function
dolike
(
ident
,
verb
)
{
$
(
'
#like-rotator-
'
+
ident
.
toString
()).
show
();
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
();
collapseHeight
();
liking
=
0
;
if
(
typeof
conv_mode
==
typeof
undefined
)
conv_mode
=
''
;
$
.
get
(
'
like/
'
+
ident
.
toString
()
+
'
?verb=
'
+
verb
+
'
&conv_mode=
'
+
conv_mode
,
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
();
collapseHeight
();
liking
=
0
;
}
});
liking
=
1
;
}
...
...
view/tpl/build_query.tpl
View file @
c0adf31d
...
...
@@ -2,6 +2,9 @@
var
bParam_cmd
=
"
{
{
$baseurl
}
}/update/{
{
$pgtype
}
}
"
;
{
{
if
$conv_mode
}
}
var
conv_mode
=
'
{
{
$conv_mode
}
}
'
;
{
{/
if
}
}
var
bParam_uid
=
{
{
$uid
}
};
var
bParam_gid
=
{
{
$gid
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment