From 766c4778cb0a678ef7f55e56cbd11497a73ae6cb Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 8 Feb 2011 15:08:07 -0800 Subject: modify tag handling and replies to stnet --- mod/item.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 38ef580af..2264ea5b9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -25,6 +25,7 @@ function item_post(&$a) { $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0); $parent_item = null; + $parent_contact = null; if($parent) { $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", @@ -35,6 +36,14 @@ function item_post(&$a) { goaway($a->get_baseurl() . "/" . $_POST['return'] ); } $parent_item = $r[0]; + if($parent_item['contact-id'] && $uid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($parent_item['contact-id']), + intval($uid) + ); + if(count($r)) + $parent_contact = $r[0]; + } } $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0); @@ -185,8 +194,13 @@ function item_post(&$a) { $str_tags = ''; $inform = ''; + $tags = get_tags($body); + if(($parent_contact) && ($parent_contact['network'] === 'stat') && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) { + $body = '@' . $parent_contact['nick'] . ' ' . $body; + $tags[] = '@' . $parent_contact['nick']; + } if(count($tags)) { foreach($tags as $tag) { @@ -199,6 +213,7 @@ function item_post(&$a) { continue; } if(strpos($tag,'@') === 0) { + $stat = false; $name = substr($tag,1); if((strpos($name,'@')) || (strpos($name,'http://'))) { $newname = $name; @@ -231,6 +246,8 @@ function item_post(&$a) { ); } if(count($r)) { + if($r[0]['network'] === 'stat') + $stat = true; $profile = $r[0]['url']; $newname = $r[0]['name']; if(strlen($inform)) @@ -239,7 +256,8 @@ function item_post(&$a) { } } if($profile) { - $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname . '[/url]', $body); + if(! $stat) + $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname . '[/url]', $body); $profile = str_replace(',','%2c',$profile); if(strlen($str_tags)) $str_tags .= ','; @@ -249,6 +267,8 @@ function item_post(&$a) { } } + + $wall = 0; if($post_type === 'wall' || $post_type === 'wall-comment') $wall = 1; -- cgit v1.2.3 From f70a0b028288fa13c64f1ffaa310765a95347dac Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 8 Feb 2011 18:44:30 -0800 Subject: more graceful handling of some statusnet followups --- mod/follow.php | 27 ++++++++++++++++++++++++--- mod/item.php | 12 +++++++----- mod/salmon.php | 2 +- 3 files changed, 32 insertions(+), 9 deletions(-) (limited to 'mod') diff --git a/mod/follow.php b/mod/follow.php index 8c1dc348f..eaee7d5ac 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -15,7 +15,7 @@ function follow_post(&$a) { $email_conversant = false; if($url) { - $links = lrdd($url); + $links = @lrdd($url); if(count($links)) { foreach($links as $link) { if($link['@attributes']['rel'] === NAMESPACE_DFRN) @@ -30,6 +30,26 @@ function follow_post(&$a) { $profile = $link['@attributes']['href']; } + + // Status.Net can have more than one profile URL. We need to match the profile URL + // to a contact on incoming messages to prevent spam, and we won't know which one + // to match. So in case of two, one of them is stored as an alias. Only store URL's + // and not webfinger user@host aliases. If they've got more than two non-email style + // aliases, let's hope we're lucky and get one that matches the feed author-uri because + // otherwise we're screwed. + + foreach($links as $link) { + if($link['@attributes']['rel'] === 'alias') { + if(strpos($link['@attributes']['href'],'@') === false) { + if(isset($profile)) { + if($link['@attributes']['href'] !== $profile) + $alias = $link['@attributes']['href']; + } + else + $profile = $link['@attributes']['href']; + } + } + } } else { if((strpos($orig_url,'@')) && validate_email($orig_url)) { @@ -165,12 +185,13 @@ function follow_post(&$a) { } else { // create contact record - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, + $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 0, 0, 0 ) ", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 0, 0, 0 ) ", intval(local_user()), dbesc(datetime_convert()), dbesc($profile), + dbesc($alias), dbesc($notify), dbesc($poll), dbesc($vcard['fn']), diff --git a/mod/item.php b/mod/item.php index 2264ea5b9..737fe8341 100644 --- a/mod/item.php +++ b/mod/item.php @@ -246,18 +246,20 @@ function item_post(&$a) { ); } if(count($r)) { - if($r[0]['network'] === 'stat') - $stat = true; $profile = $r[0]['url']; - $newname = $r[0]['name']; + if($r[0]['network'] === 'stat') { + $newname = $r[0]['nick']; + $stat = true; + } + else + $newname = $r[0]['name']; if(strlen($inform)) $inform .= ','; $inform .= 'cid:' . $r[0]['id']; } } if($profile) { - if(! $stat) - $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname . '[/url]', $body); + $body = str_replace('@' . $name, '@' . '[url=' . $profile . ']' . $newname . '[/url]', $body); $profile = str_replace(',','%2c',$profile); if(strlen($str_tags)) $str_tags .= ','; diff --git a/mod/salmon.php b/mod/salmon.php index 8c7d921c8..885ba470c 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -177,7 +177,7 @@ function salmon_post(&$a) { * */ - $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `lrdd` = '%s') + $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `alias` = '%s') AND `uid` = %d LIMIT 1", dbesc($author_link), dbesc($author_link), -- cgit v1.2.3 From de2c9531db2332f0c0e944add6f9d85e88476dff Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 9 Feb 2011 19:39:49 -0800 Subject: post permission hooks --- mod/item.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 737fe8341..a83373f59 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,6 +22,8 @@ function item_post(&$a) { $uid = local_user(); + call_hooks('post_local_start', $_POST); + $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0); $parent_item = null; -- cgit v1.2.3 From 40777b132b86cb832c0ce18b9a65a137a085a41b Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 9 Feb 2011 19:56:40 -0800 Subject: log ignored pubsub deliveries --- mod/pubsub.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/pubsub.php b/mod/pubsub.php index 4f4ed2f16..df27c6bc2 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -105,8 +105,10 @@ function pubsub_post(&$a) { intval($contact_id), intval($importer['uid']) ); - if(! count($r)) + if(! count($r)) { + logger('pubsub: no contact record - ignored'); hub_post_return(); + } $contact = $r[0]; -- cgit v1.2.3 From 2e78ed00f6b247c90b1bc78ff4801e337e6d8d86 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 10 Feb 2011 00:32:09 -0800 Subject: general purpose callback landing page - e.g. for facebook plugin --- mod/cb.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 mod/cb.php (limited to 'mod') diff --git a/mod/cb.php b/mod/cb.php new file mode 100644 index 000000000..6375d2398 --- /dev/null +++ b/mod/cb.php @@ -0,0 +1,24 @@ + Date: Fri, 11 Feb 2011 02:35:19 -0800 Subject: toggles "post to facebook, post to twitter", etc. --- mod/network.php | 5 ++++- mod/profile.php | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index b0196f92a..f11db45a8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -79,8 +79,10 @@ function network_content(&$a, $update = 0) { $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $jotplugins = ""; + $jotplugins = ''; + $jotnets = ''; call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); @@ -90,6 +92,7 @@ function network_content(&$a, $update = 0) { '$defloc' => $a->user['default-location'], '$visitor' => 'block', '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb), diff --git a/mod/profile.php b/mod/profile.php index 3b4616a34..8ec29d382 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -135,9 +135,12 @@ function profile_content(&$a, $update = 0) { else $lockstate = 'unlock'; - $jotplugins = ""; + $jotplugins = ''; + $jotnets = ''; call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); $o .= replace_macros($tpl,array( @@ -147,6 +150,7 @@ function profile_content(&$a, $update = 0) { '$visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'), '$lockstate' => $lockstate, '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$bang' => '', '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''), -- cgit v1.2.3