diff options
author | Fabio Comuni <fabrix.xm@gmail.com> | 2011-10-03 08:13:40 +0200 |
---|---|---|
committer | Fabio Comuni <fabrix.xm@gmail.com> | 2011-10-03 08:13:40 +0200 |
commit | 2465b3274aacaf81c50d2bd11375f02cb9b49d54 (patch) | |
tree | 48b0e70acffedfa4c9226a6b436c5b62556b3470 /include | |
parent | 60e0f79b9f9e94b19cc412eac41e5d8f8fec2383 (diff) | |
parent | 297ab898b7642cf8251405cb60e787222f4e5974 (diff) | |
download | volse-hubzilla-2465b3274aacaf81c50d2bd11375f02cb9b49d54.tar.gz volse-hubzilla-2465b3274aacaf81c50d2bd11375f02cb9b49d54.tar.bz2 volse-hubzilla-2465b3274aacaf81c50d2bd11375f02cb9b49d54.zip |
Merge remote-tracking branch 'friendika/master'
Diffstat (limited to 'include')
-rw-r--r-- | include/delivery.php | 2 | ||||
-rw-r--r-- | include/items.php | 44 | ||||
-rw-r--r-- | include/notifier.php | 3 |
3 files changed, 40 insertions, 9 deletions
diff --git a/include/delivery.php b/include/delivery.php index 3ab820b62..46112d78e 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -96,6 +96,8 @@ function delivery_run($argv, $argc){ $uid = $r[0]['uid']; $updated = $r[0]['edited']; + if(! $parent_id) + return; $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` diff --git a/include/items.php b/include/items.php index a1baf7471..32f0728c3 100644 --- a/include/items.php +++ b/include/items.php @@ -1491,6 +1491,20 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee lose_follower($importer,$contact,$datarray,$item); return; } + + if(activity_match($datarray['verb'],ACTIVITY_REQ_FRIEND)) { + logger('consume-feed: New friend request'); + new_follower($importer,$contact,$datarray,$item,true); + return; + } + if(activity_match($datarray['verb'],ACTIVITY_UNFRIEND)) { + lose_sharer($importer,$contact,$datarray,$item); + return; + } + + + + if(! is_array($contact)) return; @@ -1522,7 +1536,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee } } -function new_follower($importer,$contact,$datarray,$item) { +function new_follower($importer,$contact,$datarray,$item,$sharing = false) { $url = notags(trim($datarray['author-link'])); $name = notags(trim($datarray['author-name'])); $photo = notags(trim($datarray['author-avatar'])); @@ -1532,14 +1546,14 @@ function new_follower($importer,$contact,$datarray,$item) { $nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']; if(is_array($contact)) { - if($contact['network'] == 'stat' && $contact['rel'] == CONTACT_IS_SHARING) { + if(($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING) + || ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) { $r = q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(CONTACT_IS_FRIEND), intval($contact['id']), intval($importer['uid']) ); } - // send email notification to owner? } else { @@ -1555,13 +1569,12 @@ function new_follower($importer,$contact,$datarray,$item) { dbesc($name), dbesc($nick), dbesc($photo), - dbesc('stat'), - intval(CONTACT_IS_FOLLOWER) + dbesc(($sharing) ? NETWORK_ZOT : NETWORK_OSTATUS), + intval(($sharing) ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER) ); - $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 AND `rel` = %d LIMIT 1", + $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1", intval($importer['uid']), - dbesc($url), - intval(CONTACT_IS_FOLLOWER) + dbesc($url) ); if(count($r)) $contact_record = $r[0]; @@ -1593,7 +1606,7 @@ function new_follower($importer,$contact,$datarray,$item) { '$sitename' => $a->config['sitename'] )); $res = mail($r[0]['email'], - t("You have a new follower at ") . $a->config['sitename'], + (($sharing) ? t('A new person is sharing with you at ') : t("You have a new follower at ")) . $a->config['sitename'], $email, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" @@ -1617,6 +1630,19 @@ function lose_follower($importer,$contact,$datarray,$item) { } } +function lose_sharer($importer,$contact,$datarray,$item) { + + if(($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) { + q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d LIMIT 1", + intval(CONTACT_IS_FOLLOWER), + intval($contact['id']) + ); + } + else { + contact_remove($contact['id']); + } +} + function subscribe_to_hub($url,$importer,$contact,$submode = 'subscribe') { diff --git a/include/notifier.php b/include/notifier.php index 864fa517b..d1cd1cc73 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -123,6 +123,9 @@ function notifier_run($argv, $argc){ $uid = $r[0]['uid']; $updated = $r[0]['edited']; + if(! $parent_id) + return; + $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d ORDER BY `id` ASC", intval($parent_id) |