sync likes
This commit is contained in:
parent
00b480527a
commit
4abfd4053a
@ -4,7 +4,7 @@ We need much more than this, but here are areas where developers can help. Pleas
|
||||
|
||||
[li]Documentation - see Red Documentation Project To-Do List[/li]
|
||||
[li]Include TOS link in registration/verification email[/li]
|
||||
[li](done) forum widget with unread counts (requires the DB schema changes from v3/hubzilla to be viable)[/li]
|
||||
[li]Auto preview posts/comments (configurable timer kicks in the preview if not 0)[/li]
|
||||
[li]Create bug tracker module[/li]
|
||||
[li]translation plugins - moses or apertium[/li]
|
||||
[li]plugins - provide 'disable' which is softer than 'uninstall' for those plugins which create additional DB tables[/li]
|
||||
|
@ -762,6 +762,43 @@ function sync_menus($channel,$menus) {
|
||||
|
||||
|
||||
|
||||
function import_likes($channel,$likes) {
|
||||
if($channel && $likes) {
|
||||
foreach($likes as $like) {
|
||||
if($like['deleted']) {
|
||||
q("delete from likes where liker = '%s' and likee = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s'",
|
||||
dbesc($like['liker']),
|
||||
dbesc($like['likee']),
|
||||
dbesc($like['verb']),
|
||||
dbesc($like['target_type']),
|
||||
dbesc($like['target_id'])
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($like['id']);
|
||||
unset($like['iid']);
|
||||
$like['channel_id'] = $channel['channel_id'];
|
||||
$r = q("select * from likes where liker = '%s' and likee = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' and i_mid = '%s'",
|
||||
dbesc($like['liker']),
|
||||
dbesc($like['likee']),
|
||||
dbesc($like['verb']),
|
||||
dbesc($like['target_type']),
|
||||
dbesc($like['target_id']),
|
||||
dbesc($like['i_mid'])
|
||||
);
|
||||
if($r)
|
||||
continue;
|
||||
|
||||
dbesc_array($config);
|
||||
$r = dbq("INSERT INTO likes (`"
|
||||
. implode("`, `", array_keys($like))
|
||||
. "`) VALUES ('"
|
||||
. implode("', '", array_values($like))
|
||||
. "')" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -2888,6 +2888,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
|
||||
if(array_key_exists('obj',$arr) && $arr['obj'])
|
||||
sync_objs($channel,$arr['obj']);
|
||||
|
||||
if(array_key_exists('likes',$arr) && $arr['likes'])
|
||||
import_likes($channel,$arr['likes']);
|
||||
|
||||
if(array_key_exists('app',$arr) && $arr['app'])
|
||||
sync_apps($channel,$arr['app']);
|
||||
|
||||
|
@ -432,6 +432,9 @@ function import_post(&$a) {
|
||||
if(is_array($data['obj']))
|
||||
import_objs($channel,$data['obj']);
|
||||
|
||||
if(is_array($data['likes']))
|
||||
import_likes($channel,$data['likes']);
|
||||
|
||||
if(is_array($data['app']))
|
||||
import_apps($channel,$data['app']);
|
||||
|
||||
|
16
mod/like.php
16
mod/like.php
@ -219,6 +219,9 @@ function like_content(&$a) {
|
||||
);
|
||||
|
||||
if($z) {
|
||||
$z[0]['deleted'] = 1;
|
||||
build_sync_packet($ch[0]['channel_id'],array('likes' => $z));
|
||||
|
||||
q("delete from likes where id = %d limit 1",
|
||||
intval($z[0]['id'])
|
||||
);
|
||||
@ -497,7 +500,18 @@ function like_content(&$a) {
|
||||
dbesc($obj_id),
|
||||
dbesc(($target) ? $target : $object)
|
||||
);
|
||||
};
|
||||
$r = q("select * from likes where liker = '%s' and likee = '%s' and i_mid = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' ",
|
||||
dbesc($observer['xchan_hash']),
|
||||
dbesc($ch[0]['channel_hash']),
|
||||
dbesc($mid),
|
||||
dbesc($activity),
|
||||
dbesc(($tgttype)? $tgttype : $objtype),
|
||||
dbesc($obj_id)
|
||||
);
|
||||
if($r)
|
||||
build_sync_packet($ch[0]['channel_id'],array('likes' => $r));
|
||||
|
||||
}
|
||||
|
||||
|
||||
proc_run('php',"include/notifier.php","like","$post_id");
|
||||
|
Reference in New Issue
Block a user