more work on import & sync of private mail and conversations
This commit is contained in:
parent
8af3dc140e
commit
b33a9a71f6
@ -790,7 +790,7 @@ function import_likes($channel,$likes) {
|
|||||||
if($r)
|
if($r)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dbesc_array($config);
|
dbesc_array($like);
|
||||||
$r = dbq("INSERT INTO likes (`"
|
$r = dbq("INSERT INTO likes (`"
|
||||||
. implode("`, `", array_keys($like))
|
. implode("`, `", array_keys($like))
|
||||||
. "`) VALUES ('"
|
. "`) VALUES ('"
|
||||||
@ -800,6 +800,71 @@ function import_likes($channel,$likes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function import_conv($channel,$convs) {
|
||||||
|
if($channel && $convs) {
|
||||||
|
foreach($convs as $conv) {
|
||||||
|
if($conv['deleted']) {
|
||||||
|
q("delete from conv where guid = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($conv['guid']),
|
||||||
|
intval($channel['channel_id'])
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($conv['id']);
|
||||||
|
|
||||||
|
$conv['uid'] = $channel['channel_id'];
|
||||||
|
$conv['subject'] = str_rot47(base64url_encode($conv['subject']));
|
||||||
|
|
||||||
|
$r = q("select id from conv where guid = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($conv['guid']),
|
||||||
|
intval($channel['channel_id'])
|
||||||
|
);
|
||||||
|
if($r)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dbesc_array($conv);
|
||||||
|
$r = dbq("INSERT INTO conv (`"
|
||||||
|
. implode("`, `", array_keys($conv))
|
||||||
|
. "`) VALUES ('"
|
||||||
|
. implode("', '", array_values($conv))
|
||||||
|
. "')" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function import_mail($channel,$mails) {
|
||||||
|
if($channel && $mails) {
|
||||||
|
foreach($mails as $mail) {
|
||||||
|
if(array_key_exists('flags',$mail) && in_array('deleted',$mail['flags'])) {
|
||||||
|
q("delete from mail where mid = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($mail['message_id']),
|
||||||
|
intval($channel['channel_id'])
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$m = get_mail_elements($mail);
|
||||||
|
if(! $m)
|
||||||
|
continue;
|
||||||
|
if($mail['conv_guid']) {
|
||||||
|
$x = q("select id from conv where guid = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($mail['conv_guid']),
|
||||||
|
intval($channel['channel_id'])
|
||||||
|
);
|
||||||
|
if($x) {
|
||||||
|
$m['convid'] = $x[0]['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$m['aid'] = $channel['channel_account_id'];
|
||||||
|
$m['uid'] = $channel['channel_id'];
|
||||||
|
mail_store($m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3002,6 +3002,12 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
|
|||||||
if(array_key_exists('chatroom',$arr) && $arr['chatroom'])
|
if(array_key_exists('chatroom',$arr) && $arr['chatroom'])
|
||||||
sync_chatrooms($channel,$arr['chatroom']);
|
sync_chatrooms($channel,$arr['chatroom']);
|
||||||
|
|
||||||
|
if(array_key_exists('conv',$arr) && $arr['conv'])
|
||||||
|
import_conv($channel,$arr['conv']);
|
||||||
|
|
||||||
|
if(array_key_exists('mail',$arr) && $arr['mail'])
|
||||||
|
import_mail($channel,$arr['mail']);
|
||||||
|
|
||||||
if(array_key_exists('event',$arr) && $arr['event'])
|
if(array_key_exists('event',$arr) && $arr['event'])
|
||||||
sync_events($channel,$arr['event']);
|
sync_events($channel,$arr['event']);
|
||||||
|
|
||||||
|
@ -441,6 +441,12 @@ function import_post(&$a) {
|
|||||||
if(is_array($data['chatroom']))
|
if(is_array($data['chatroom']))
|
||||||
import_chatrooms($channel,$data['chatroom']);
|
import_chatrooms($channel,$data['chatroom']);
|
||||||
|
|
||||||
|
if(is_array($data['conv']))
|
||||||
|
import_conv($channel,$data['conv']);
|
||||||
|
|
||||||
|
if(is_array($data['mail']))
|
||||||
|
import_mail($channel,$data['mail']);
|
||||||
|
|
||||||
if(is_array($data['event']))
|
if(is_array($data['event']))
|
||||||
import_events($channel,$data['event']);
|
import_events($channel,$data['event']);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user