diff options
author | friendica <info@friendica.com> | 2014-09-23 03:03:14 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-09-23 03:03:14 -0700 |
commit | 509a85cb12636dc01b59935febf9419cfb02fd48 (patch) | |
tree | 3703f577165e6ef917b97d354bba09e93aebfb57 /include/diaspora.php | |
parent | 72ec78d0270ecc5036e02db984b0a5c5fd293c8b (diff) | |
download | volse-hubzilla-509a85cb12636dc01b59935febf9419cfb02fd48.tar.gz volse-hubzilla-509a85cb12636dc01b59935febf9419cfb02fd48.tar.bz2 volse-hubzilla-509a85cb12636dc01b59935febf9419cfb02fd48.zip |
more work on d* private messages
Diffstat (limited to 'include/diaspora.php')
-rwxr-xr-x | include/diaspora.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/include/diaspora.php b/include/diaspora.php index 6f504b460..74dad177a 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1532,6 +1532,12 @@ function diaspora_conversation($importer,$xml,$msg) { continue; } + $key = get_config('system','pubkey'); + if($subject) + $subject = json_encode(crypto_encapsulate($subject,$key)); + if($body) + $body = json_encode(crypto_encapsulate($body,$key)); + q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s')", intval($importer['channel_id']), intval($conversation['id']), @@ -1539,7 +1545,7 @@ function diaspora_conversation($importer,$xml,$msg) { dbesc($importer['channel_hash']), dbesc($subject), dbesc($body), - 0, + intval(MAIL_OBSCURED), dbesc($msg_guid), dbesc($parent_uri), dbesc($msg_created_at) @@ -1588,7 +1594,7 @@ function diaspora_message($importer,$xml,$msg) { $msg_diaspora_handle = notags(unxmlify($xml->diaspora_handle)); $msg_conversation_guid = notags(unxmlify($xml->conversation_guid)); - $parent_uri = $diaspora_handle . ':' . $msg_parent_guid; + $parent_uri = $msg_parent_guid; $contact = diaspora_get_contact_by_handle($importer['channel_id'],$msg_diaspora_handle); if(! $contact) { @@ -1607,7 +1613,7 @@ function diaspora_message($importer,$xml,$msg) { intval($importer['channel_id']), dbesc($msg_conversation_guid) ); - if(count($c)) + if($c) $conversation = $c[0]; else { logger('diaspora_message: conversation not available.'); @@ -1637,15 +1643,21 @@ function diaspora_message($importer,$xml,$msg) { return; } - $r = q("select id from mail where `uri` = '%s' and uid = %d limit 1", + $r = q("select id from mail where mid = '%s' and uid = %d limit 1", dbesc($message_id), intval($importer['channel_id']) ); - if(count($r)) { + if($r) { logger('diaspora_message: duplicate message already delivered.', LOGGER_DEBUG); return; } + $key = get_config('system','pubkey'); + if($subject) + $subject = json_encode(crypto_encapsulate($subject,$key)); + if($body) + $body = json_encode(crypto_encapsulate($body,$key)); + q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', '%d','%s','%s','%s')", intval($importer['channel_id']), intval($conversation['id']), @@ -1653,7 +1665,7 @@ function diaspora_message($importer,$xml,$msg) { dbesc($importer['xchan_hash']), dbesc($conversation['subject']), dbesc($body), - 0, + intval(MAIL_OBSCURED), dbesc($msg_guid), dbesc($parent_uri), dbesc($msg_created_at) |