- if($importer["page-flags"] == PAGE_FREELOVE)
- $new_relation = CONTACT_IS_FRIEND;
- else
- $new_relation = CONTACT_IS_FOLLOWER;
-
- $r = q("UPDATE `contact` SET `rel` = %d,
- `name-date` = '%s',
- `uri-date` = '%s',
- `blocked` = 0,
- `pending` = 0,
- `writable` = 1
- WHERE `id` = %d
- ",
- intval($new_relation),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($contact_record["id"])
- );
+ $ret = q("INSERT INTO `intro` (`uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
+ VALUES (%d, %d, %d, %d, '%s', '%s', '%s')",
+ intval($importer["uid"]),
+ intval($contact_record["id"]),
+ 0,
+ 0,
+ dbesc(t("Sharing notification from Diaspora network")),
+ dbesc($hash),
+ dbesc(datetime_convert())
+ );
+ } else {
+
+ // automatic friend approval
+
+ update_contact_avatar($contact_record["photo"],$importer["uid"],$contact_record["id"]);
+
+ // technically they are sharing with us (CONTACT_IS_SHARING),
+ // but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
+ // we are going to change the relationship and make them a follower.
+
+ if($importer["page-flags"] == PAGE_FREELOVE)
+ $new_relation = CONTACT_IS_FRIEND;
+ else
+ $new_relation = CONTACT_IS_FOLLOWER;
+
+ $r = q("UPDATE `contact` SET `rel` = %d,
+ `name-date` = '%s',
+ `uri-date` = '%s',
+ `blocked` = 0,
+ `pending` = 0,
+ `writable` = 1
+ WHERE `id` = %d
+ ",
+ intval($new_relation),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($contact_record["id"])
+ );
+
+ $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
+ if($u)
+ $ret = diaspora_share($u[0], $contact_record);
+ }