aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-11-01 16:36:35 -0700
committerfriendica <info@friendica.com>2012-11-01 16:36:35 -0700
commit42ac706b9f9589b2c38aae45156b6e1e49f8ca8d (patch)
tree188b109a8b714b2854b2a493b84de5e4c63690ea /include
parent9bf4508ffb626d1aa2c9591b700e985b00abe577 (diff)
downloadvolse-hubzilla-42ac706b9f9589b2c38aae45156b6e1e49f8ca8d.tar.gz
volse-hubzilla-42ac706b9f9589b2c38aae45156b6e1e49f8ca8d.tar.bz2
volse-hubzilla-42ac706b9f9589b2c38aae45156b6e1e49f8ca8d.zip
more progress on follow - should be able to import the xchan and photos.
Diffstat (limited to 'include')
-rw-r--r--include/Photo.php40
-rw-r--r--include/follow.php74
2 files changed, 69 insertions, 45 deletions
diff --git a/include/Photo.php b/include/Photo.php
index 819f86059..f77605b98 100644
--- a/include/Photo.php
+++ b/include/Photo.php
@@ -523,18 +523,18 @@ class Photo {
- public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
+ public function store($uid, $xchan, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
- $x = q("select id from photo where `resource_id` = '%s' and uid = %d and `contact-id` = %d and `scale` = %d limit 1",
+ $x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `scale` = %d limit 1",
dbesc($rid),
intval($uid),
- intval($cid),
+ intval($xchan),
intval($scale)
);
if(count($x)) {
$r = q("UPDATE `photo`
set `uid` = %d,
- `contact-id` = %d,
+ `xchan` = '%s',
`resource_id` = '%s',
`created` = '%s',
`edited` = '%s',
@@ -553,7 +553,7 @@ class Photo {
where id = %d limit 1",
intval($uid),
- intval($cid),
+ dbesc($xchan),
dbesc($rid),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
@@ -574,10 +574,10 @@ class Photo {
}
else {
$r = q("INSERT INTO `photo`
- ( `uid`, `contact-id`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
+ ( `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
intval($uid),
- intval($cid),
+ dbesc($xchan),
dbesc($rid),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
@@ -644,15 +644,14 @@ function guess_image_type($filename, $fromcurl=false) {
}
-function import_profile_photo($photo,$uid,$cid) {
+function import_profile_photo($photo,$xchan) {
$a = get_app();
- $r = q("select `resource_id` from photo where `uid` = %d and `contact-id` = %d and `scale` = 4 and `album` = 'Contact Photos' limit 1",
- intval($uid),
- intval($cid)
+ $r = q("select `resource_id` from photo where xchan = '%s' and `scale` = 4 limit 1",
+ dbesc($xchan)
);
- if(count($r)) {
+ if($r) {
$hash = $r[0]['resource_id'];
}
else {
@@ -670,28 +669,28 @@ function import_profile_photo($photo,$uid,$cid) {
$img->scaleImageSquare(175);
- $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 );
+ $r = $img->store(0, $xchan, $hash, $filename, 'Contact Photos', 4 );
if($r === false)
$photo_failure = true;
$img->scaleImage(80);
- $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5 );
+ $r = $img->store(0, $xchan, $hash, $filename, 'Contact Photos', 5 );
if($r === false)
$photo_failure = true;
$img->scaleImage(48);
- $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6 );
+ $r = $img->store(0, $xchan, $hash, $filename, 'Contact Photos', 6 );
if($r === false)
$photo_failure = true;
- $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
- $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
- $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
+ $photo = $a->get_baseurl() . '/photo/' . $hash . '-4';
+ $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5';
+ $micro = $a->get_baseurl() . '/photo/' . $hash . '-6';
}
else
$photo_failure = true;
@@ -700,8 +699,9 @@ function import_profile_photo($photo,$uid,$cid) {
$photo = $a->get_baseurl() . '/images/person-175.jpg';
$thumb = $a->get_baseurl() . '/images/person-80.jpg';
$micro = $a->get_baseurl() . '/images/person-48.jpg';
+ $type = 'image/jpeg';
}
- return(array($photo,$thumb,$micro));
+ return(array($photo,$thumb,$micro,$type));
}
diff --git a/include/follow.php b/include/follow.php
index 405e926df..e9c6c1ee5 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -70,6 +70,8 @@ function new_contact($uid,$url,$channel,$interactive = false) {
$xchan_hash = base64_urlencode(hash('whirlpool',$j->quid . $j->guid_sg, true));
+// FIXME - verify the signature
+
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($xchan_hash)
);
@@ -90,15 +92,60 @@ function new_contact($uid,$url,$channel,$interactive = false) {
dbesc($j->photo_updated),
dbesc($j->name_updated)
);
- }
+ require_once("Photo.php");
+
+ $photos = import_profile_photo($j->photo,0,$contact_id);
+ $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s' = '%s', xchan_photo_mimetype = '%s'
+ where xchan_hash = '%s' limit 1",
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc($photos[3]),
+ dbesc($xchan_hash)
+ );
+ }
+
+ if($j->locations) {
+ foreach($j->locations as $location) {
+ $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' limit 1",
+ dbesc($xchan_hash),
+ dbesc($location['url'])
+ );
+ if($r)
+ continue;
+
+// FIXME verify the signature
+
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey)
+ values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s')",
+ dbesc($j->guid),
+ dbesc($j->guid_sig),
+ dbesc($xchan_hash),
+ dbesc($location['address']),
+ intval((intval($location['primary'])) ? HUBLOC_FLAGS_PRIMARY : 0),
+ dbesc($location['url']),
+ dbesc($location['url_sig']),
+ dbesc($location['host']),
+ dbesc($location['callback']),
+ dbesc($location['sitekey'])
+ );
+
+ }
+ }
// Do we already have an abook entry?
// go directly to the abook edit page.
+ // Else create an entry
+
+
+
+ // Then send a ping/message to the other side
+
@@ -151,31 +198,8 @@ function new_contact($uid,$url,$channel,$interactive = false) {
group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
}
- require_once("Photo.php");
-
- $photos = import_profile_photo($ret['photo'],$uid,$contact_id);
-
- $r = q("UPDATE `contact` SET `photo` = '%s',
- `thumb` = '%s',
- `micro` = '%s',
- `name_date` = '%s',
- `uri_date` = '%s',
- `avatar_date` = '%s'
- WHERE `id` = %d LIMIT 1
- ",
- dbesc($photos[0]),
- dbesc($photos[1]),
- dbesc($photos[2]),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($contact_id)
- );
-
-
- // pull feed and consume it
*/
- proc_run('php',"include/poller.php","$contact_id");
+
$result['success'] = true;
return $result;