summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/OStatus/OStatusPlugin.php80
-rw-r--r--plugins/OStatus/classes/HubSub.php2
-rw-r--r--plugins/OStatus/lib/feeddiscovery.php2
-rw-r--r--plugins/RSSCloud/RSSCloudNotifier.php2
-rw-r--r--plugins/RSSCloud/RSSCloudRequestNotify.php7
-rw-r--r--plugins/RequireValidatedEmail/README2
-rw-r--r--plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php23
-rw-r--r--plugins/RequireValidatedEmail/locale/RequireValidatedEmail.po31
8 files changed, 140 insertions, 9 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index bdcaae366..a97f3475b 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -322,6 +322,86 @@ class OStatusPlugin extends Plugin
}
/**
+ * Allow remote profile references to be used in commands:
+ * sub update@status.net
+ * whois evan@identi.ca
+ * reply http://identi.ca/evan hey what's up
+ *
+ * @param Command $command
+ * @param string $arg
+ * @param Profile &$profile
+ * @return hook return code
+ */
+ function onStartCommandGetProfile($command, $arg, &$profile)
+ {
+ $oprofile = $this->pullRemoteProfile($arg);
+ if ($oprofile && !$oprofile->isGroup()) {
+ $profile = $oprofile->localProfile();
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Allow remote group references to be used in commands:
+ * join group+statusnet@identi.ca
+ * join http://identi.ca/group/statusnet
+ * drop identi.ca/group/statusnet
+ *
+ * @param Command $command
+ * @param string $arg
+ * @param User_group &$group
+ * @return hook return code
+ */
+ function onStartCommandGetGroup($command, $arg, &$group)
+ {
+ $oprofile = $this->pullRemoteProfile($arg);
+ if ($oprofile && $oprofile->isGroup()) {
+ $group = $oprofile->localGroup();
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ protected function pullRemoteProfile($arg)
+ {
+ $oprofile = null;
+ if (preg_match('!^((?:\w+\.)*\w+@(?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+)$!', $arg)) {
+ // webfinger lookup
+ try {
+ return Ostatus_profile::ensureWebfinger($arg);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, 'Webfinger lookup failed for ' .
+ $arg . ': ' . $e->getMessage());
+ }
+ }
+
+ // Look for profile URLs, with or without scheme:
+ $urls = array();
+ if (preg_match('!^https?://((?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+(?:/\w+)+)$!', $arg)) {
+ $urls[] = $arg;
+ }
+ if (preg_match('!^((?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+(?:/\w+)+)$!', $arg)) {
+ $schemes = array('http', 'https');
+ foreach ($schemes as $scheme) {
+ $urls[] = "$scheme://$arg";
+ }
+ }
+
+ foreach ($urls as $url) {
+ try {
+ return Ostatus_profile::ensureProfile($url);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, 'Profile lookup failed for ' .
+ $arg . ': ' . $e->getMessage());
+ }
+ }
+ return null;
+ }
+
+ /**
* Make sure necessary tables are filled out.
*/
function onCheckSchema() {
diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php
index 3120a70f9..c420b3eef 100644
--- a/plugins/OStatus/classes/HubSub.php
+++ b/plugins/OStatus/classes/HubSub.php
@@ -192,7 +192,7 @@ class HubSub extends Memcached_DataObject
// Any existing query string parameters must be preserved
$url = $this->callback;
- if (strpos('?', $url) !== false) {
+ if (strpos($url, '?') !== false) {
$url .= '&';
} else {
$url .= '?';
diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php
index 7afb71bdc..ff76b229e 100644
--- a/plugins/OStatus/lib/feeddiscovery.php
+++ b/plugins/OStatus/lib/feeddiscovery.php
@@ -129,7 +129,7 @@ class FeedDiscovery
function initFromResponse($response)
{
if (!$response->isOk()) {
- throw new FeedSubBadResponseException($response->getCode());
+ throw new FeedSubBadResponseException($response->getStatus());
}
$sourceurl = $response->getUrl();
diff --git a/plugins/RSSCloud/RSSCloudNotifier.php b/plugins/RSSCloud/RSSCloudNotifier.php
index d454691c8..9e7b53680 100644
--- a/plugins/RSSCloud/RSSCloudNotifier.php
+++ b/plugins/RSSCloud/RSSCloudNotifier.php
@@ -152,7 +152,7 @@ class RSSCloudNotifier
function notify($profile)
{
$feed = common_path('api/statuses/user_timeline/') .
- $profile->nickname . '.rss';
+ $profile->id . '.rss';
$cloudSub = new RSSCloudSubscription();
diff --git a/plugins/RSSCloud/RSSCloudRequestNotify.php b/plugins/RSSCloud/RSSCloudRequestNotify.php
index d76c08d37..030529534 100644
--- a/plugins/RSSCloud/RSSCloudRequestNotify.php
+++ b/plugins/RSSCloud/RSSCloudRequestNotify.php
@@ -270,13 +270,14 @@ class RSSCloudRequestNotifyAction extends Action
function userFromFeed($feed)
{
- // We only do profile feeds
+ // We only do canonical RSS2 profile feeds (specified by ID), e.g.:
+ // http://www.example.com/api/statuses/user_timeline/2.rss
$path = common_path('api/statuses/user_timeline/');
- $valid = '%^' . $path . '(?<nickname>.*)\.rss$%';
+ $valid = '%^' . $path . '(?<id>.*)\.rss$%';
if (preg_match($valid, $feed, $matches)) {
- $user = User::staticGet('nickname', $matches['nickname']);
+ $user = User::staticGet('id', $matches['id']);
if (!empty($user)) {
return $user;
}
diff --git a/plugins/RequireValidatedEmail/README b/plugins/RequireValidatedEmail/README
index ccd94d271..46ee24d5f 100644
--- a/plugins/RequireValidatedEmail/README
+++ b/plugins/RequireValidatedEmail/README
@@ -14,8 +14,6 @@ registered prior to that timestamp.
Todo:
-* make email field required on registration form
* add a more visible indicator that validation is still outstanding
-* localization for UI strings
* test with XMPP, API posting
diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
index 3581f1de9..ccefa14f6 100644
--- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
+++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
@@ -54,13 +54,34 @@ class RequireValidatedEmailPlugin extends Plugin
$user = User::staticGet('id', $notice->profile_id);
if (!empty($user)) { // it's a remote notice
if (!$this->validated($user)) {
- throw new ClientException(_("You must validate your email address before posting."));
+ throw new ClientException(_m("You must validate your email address before posting."));
}
}
return true;
}
/**
+ * Event handler for registration attempts; rejects the registration
+ * if email field is missing.
+ *
+ * @param RegisterAction $action
+ * @return bool hook result code
+ */
+ function onStartRegistrationTry($action)
+ {
+ $email = $action->trimmed('email');
+
+ if (empty($email)) {
+ $action->showForm(_m('You must provide an email address to register.'));
+ return false;
+ }
+
+ // Default form will run address format validation and reject if bad.
+
+ return true;
+ }
+
+ /**
* Check if a user has a validated email address or has been
* otherwise grandfathered in.
*
diff --git a/plugins/RequireValidatedEmail/locale/RequireValidatedEmail.po b/plugins/RequireValidatedEmail/locale/RequireValidatedEmail.po
new file mode 100644
index 000000000..49ac4f6f4
--- /dev/null
+++ b/plugins/RequireValidatedEmail/locale/RequireValidatedEmail.po
@@ -0,0 +1,31 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-03-10 10:05-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: RequireValidatedEmailPlugin.php:57
+msgid "You must validate your email address before posting."
+msgstr ""
+
+#: RequireValidatedEmailPlugin.php:75
+msgid "You must provide an email address to register."
+msgstr ""
+
+#: RequireValidatedEmailPlugin.php:128
+msgid ""
+"The Require Validated Email plugin disables posting for accounts that do not "
+"have a validated email address."
+msgstr ""