diff options
author | Friendika <info@friendika.com> | 2011-11-12 04:06:33 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-11-12 04:06:33 -0800 |
commit | cf82174520c4cc1024f2690e51dc903d663a5661 (patch) | |
tree | fc92667a86d4b0d2779ea63a890ebeae9f66af77 /include | |
parent | d23867f5a0564d680680e4bae3691bdecdcc183f (diff) | |
download | volse-hubzilla-cf82174520c4cc1024f2690e51dc903d663a5661.tar.gz volse-hubzilla-cf82174520c4cc1024f2690e51dc903d663a5661.tar.bz2 volse-hubzilla-cf82174520c4cc1024f2690e51dc903d663a5661.zip |
bug #198 - create activitystream 'friends with' message for Diaspora confirmations
Diffstat (limited to 'include')
-rw-r--r-- | include/diaspora.php | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/include/diaspora.php b/include/diaspora.php index 7e1e034d6..ff0c0c0d7 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -420,6 +420,8 @@ function diaspora_decode($importer,$xml) { function diaspora_request($importer,$xml) { + $a = get_app(); + $sender_handle = unxmlify($xml->sender_handle); $recipient_handle = unxmlify($xml->recipient_handle); @@ -440,7 +442,60 @@ function diaspora_request($importer,$xml) { intval($importer['uid']) ); } - // send notification? + // send notification + + $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + intval($importer['uid']) + ); + + if((count($r)) && ($r[0]['hide-friends'] == 0)) { + require_once('include/items.php'); + + $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", + intval($importer['uid']) + ); + + if(count($self)) { + + $arr = array(); + $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $importer['uid']); + $arr['uid'] = $importer['uid']; + $arr['contact-id'] = $self[0]['id']; + $arr['wall'] = 1; + $arr['type'] = 'wall'; + $arr['gravity'] = 0; + $arr['origin'] = 1; + $arr['author-name'] = $arr['owner-name'] = $self[0]['name']; + $arr['author-link'] = $arr['owner-link'] = $self[0]['url']; + $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb']; + $arr['verb'] = ACTIVITY_FRIEND; + $arr['object-type'] = ACTIVITY_OBJ_PERSON; + + $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]'; + $B = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; + $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]'; + $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; + + $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $contact['name'] . '</title>' + . '<id>' . $contact['url'] . '/' . $contact['name'] . '</id>'; + $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $contact['url'] . '" />' . "\n"); + $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $contact['thumb'] . '" />' . "\n"); + $arr['object'] .= '</link></object>' . "\n"; + $arr['last-child'] = 1; + + $arr['allow_cid'] = $user[0]['allow_cid']; + $arr['allow_gid'] = $user[0]['allow_gid']; + $arr['deny_cid'] = $user[0]['deny_cid']; + $arr['deny_gid'] = $user[0]['deny_gid']; + + $i = item_store($arr); + if($i) + proc_run('php',"include/notifier.php","activity","$i"); + + } + + } + return; } |