aboutsummaryrefslogtreecommitdiffstats
path: root/include/diaspora.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-10-13 18:32:02 -0700
committerFriendika <info@friendika.com>2011-10-13 18:32:02 -0700
commit05e26e489580c82d0db237771d159aed287c5f9b (patch)
treeafa381da3c1b0506da692df7d7738b04e20687d0 /include/diaspora.php
parent89c771a26e2eca3af8de82a5d57ce05d663ff6d5 (diff)
downloadvolse-hubzilla-05e26e489580c82d0db237771d159aed287c5f9b.tar.gz
volse-hubzilla-05e26e489580c82d0db237771d159aed287c5f9b.tar.bz2
volse-hubzilla-05e26e489580c82d0db237771d159aed287c5f9b.zip
handle diaspora profile update message
Diffstat (limited to 'include/diaspora.php')
-rw-r--r--include/diaspora.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 968aa2fd2..7207daf0c 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -38,6 +38,9 @@ function diaspora_dispatch($importer,$msg) {
elseif($xmlbase->status_message) {
$ret = diaspora_post($importer,$xmlbase->status_message);
}
+ elseif($xmlbase->profile) {
+ $ret = diaspora_profile($importer,$xmlbase->profile);
+ }
elseif($xmlbase->comment) {
$ret = diaspora_comment($importer,$xmlbase->comment,$msg);
}
@@ -995,6 +998,81 @@ function diaspora_retraction($importer,$xml) {
// NOTREACHED
}
+function diaspora_profile($importer,$xml) {
+
+ $a = get_app();
+ $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
+
+ $contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle);
+ if(! $contact)
+ return;
+
+ if($contact['blocked']) {
+ logger('diaspora_post: Ignoring this author.');
+ return 202;
+ }
+
+ $name = unxmlify($xml->first_name) . ((strlen($xml->last_name)) ? ' ' . unxmlify($xml->last_name) : '');
+ $image_url = unxmlify($xml->image_url);
+ $birthday = unxmlify($xml->birthday);
+
+ $r = q("SELECT DISTINCT ( `resource-id` ) FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `album` = 'Contact Photos' ",
+ intval($importer['uid']),
+ intval($contact['id'])
+ );
+ $oldphotos = ((count($r)) ? $r : null);
+
+ $images = import_profile_photo($image_url,$importer['uid'],$contact['id']);
+
+ // TODO handle birthdays - even though we don't know the original timezone (grrr.)
+
+ $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ dbesc($name),
+ dbesc(datetime_convert()),
+ dbesc($images[0]),
+ dbesc($images[1]),
+ dbesc($images[2]),
+ dbesc(datetime_convert()),
+ intval($contact['id']),
+ intval($importer['uid'])
+ );
+ if($r) {
+ if($oldphotos) {
+ foreach($oldphotos as $ph) {
+ q("DELETE FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `album` = 'Contact Photos' AND `resource-id` = '%s' ",
+ intval($importer['uid']),
+ intval($contact['id']),
+ dbesc($ph['resource-id'])
+ );
+ }
+ }
+ }
+
+ return;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
function diaspora_share($me,$contact) {
$a = get_app();
$myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);