]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge commit 'refs/merge-requests/36' of https://gitorious.org/social/mainline into...
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 8 Feb 2015 22:11:47 +0000 (23:11 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 8 Feb 2015 22:11:47 +0000 (23:11 +0100)
CONFIGURE
actions/networkpublic.php
classes/Managed_DataObject.php
lib/util.php
plugins/AntiBrute/AntiBrutePlugin.php
plugins/OStatus/actions/pushhub.php
plugins/OStatus/classes/FeedSub.php
plugins/OStatus/classes/HubSub.php

index 644c90452f96ddf9b5c008021fd7eb319946c67b..217b32cc7c98d250b53f46502238016ba96e136e 100644 (file)
--- a/CONFIGURE
+++ b/CONFIGURE
@@ -538,6 +538,8 @@ in php.ini to be large enough to handle your upload. In httpd.conf
 (if you're using apache), check that the LimitRequestBody directive isn't
 set too low (it's optional, so it may not be there at all).
 
+process_links: follow redirects and save all available file information
+    (mimetype, date, size, oembed, etc.). Defaults to true.
 file_quota: maximum size for a single file upload in bytes. A user can send
     any amount of notices with attachments as long as each attachment
     is smaller than file_quota.
index 79e642b773e0a13ef636a0fbe4e7fdf927538d09..7baa313bee3313a0e68274090e3d53ed2c641671 100644 (file)
@@ -61,20 +61,20 @@ class NetworkpublicAction extends PublicAction
         return array(new Feed(Feed::JSON,
                               common_local_url('ApiTimelineNetworkPublic',
                                                array('format' => 'as')),
-                              // TRANS: Link description for public timeline feed.
-                              _('Public Timeline Feed (Activity Streams JSON)')),
+                              // TRANS: Link description for the _global_ network public timeline feed.
+                              _('Network Public Timeline Feed (Activity Streams JSON)')),
                     new Feed(Feed::RSS1, common_local_url('publicrss'),
-                              // TRANS: Link description for public timeline feed.
-                              _('Public Timeline Feed (RSS 1.0)')),
+                              // TRANS: Link description for the _global_ network public timeline feed.
+                              _('Network Public Timeline Feed (RSS 1.0)')),
                      new Feed(Feed::RSS2,
                               common_local_url('ApiTimelineNetworkPublic',
                                                array('format' => 'rss')),
-                              // TRANS: Link description for public timeline feed.
-                              _('Public Timeline Feed (RSS 2.0)')),
+                              // TRANS: Link description for the _global_ network public timeline feed.
+                              _('Network Public Timeline Feed (RSS 2.0)')),
                      new Feed(Feed::ATOM,
                               common_local_url('ApiTimelineNetworkPublic',
                                                array('format' => 'atom')),
-                              // TRANS: Link description for public timeline feed.
-                              _('Public Timeline Feed (Atom)')));
+                              // TRANS: Link description for the _global_ network public timeline feed.
+                              _('Network Public Timeline Feed (Atom)')));
     }
 }
index 5ed0e525eab3ab63e36a33e56282a4115a7b2760..a628b8bee3aa1834879ecae689e4c9ca40ce2940 100644 (file)
@@ -353,6 +353,10 @@ abstract class Managed_DataObject extends Memcached_DataObject
             }
             $orig->decache();
             $this->encache();
+
+            // commit our db transaction since we won't reach the COMMIT below
+            $this->query('COMMIT');
+            // @FIXME return true only if something changed (otherwise 0)
             return true;
         }
 
@@ -384,6 +388,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
 
         // commit our db transaction
         $this->query('COMMIT');
+        // @FIXME return true only if something changed (otherwise 0)
         return $result;
     }
 }
index c365c560c233be58add270b3f98292414dd55392..a32c35395eb91ba004f48d43b828110195d54159 100644 (file)
@@ -383,6 +383,7 @@ function common_rememberme($user=null)
 
     if (!$result) {
         common_log_db_error($rm, 'INSERT', __FILE__);
+        $rm->query('ROLLBACK');
         return false;
     }
 
index 342c323016457a397a0e6f0fdef4447f25dfc9c1..365937fedf9bf4d1a6c27bbfbce31e8d1d946415 100755 (executable)
@@ -23,7 +23,8 @@ class AntiBrutePlugin extends Plugin {
         }
 
         // This probably needs some work. For example with IPv6 you can easily generate new IPs...
-        $this->client_ip = common_client_ip()[0] ?: common_client_ip()[1];   // [0] is proxy, [1] should be the real IP
+        $client_ip = common_client_ip();
+        $this->client_ip = $client_ip[0] ?: $client_ip[1];   // [0] is proxy, [1] should be the real IP
         $this->failed_attempts = (int)$this->unauthed_user->getPref(self::FAILED_LOGIN_IP_SECTION, $this->client_ip);
         switch (true) {
         case $this->failed_attempts >= 5:
index fb41c42ad354002ba5a5b78b83216e2166c065a6..5ab1fc23d833d435787eda24144c363ee15dcc93 100644 (file)
@@ -133,54 +133,61 @@ class PushHubAction extends Action
      * user or group Atom feeds.
      *
      * @param string $feed URL
-     * @return boolean true if it matches
+     * @return boolean true if it matches, false if not a recognized local feed
+     * @throws exception if local entity does not exist
      */
-    function recognizedFeed($feed)
+    protected function recognizedFeed($feed)
     {
         $matches = array();
+        // Simple mapping to local ID for user or group
         if (preg_match('!/(\d+)\.atom$!', $feed, $matches)) {
             $id = $matches[1];
             $params = array('id' => $id, 'format' => 'atom');
-            $userFeed = common_local_url('ApiTimelineUser', $params);
-            $groupFeed = common_local_url('ApiTimelineGroup', $params);
 
-            if ($feed == $userFeed) {
+            // Double-check against locally generated URLs
+            switch ($feed) {
+            case common_local_url('ApiTimelineUser', $params):
                 $user = User::getKV('id', $id);
-                if (!$user) {
+                if (!$user instanceof User) {
                     // TRANS: Client exception. %s is a feed URL.
-                    throw new ClientException(sprintt(_m('Invalid hub.topic "%s". User does not exist.'),$feed));
-                } else {
-                    return true;
+                    throw new ClientException(sprintf(_m('Invalid hub.topic "%s". User does not exist.'),$feed));
                 }
-            }
-            if ($feed == $groupFeed) {
-                $user = User_group::getKV('id', $id);
-                if (!$user) {
+                return true;
+
+            case common_local_url('ApiTimelineGroup', $params):
+                $group = Local_group::getKV('group_id', $id);
+                if (!$group instanceof Local_group) {
                     // TRANS: Client exception. %s is a feed URL.
-                    throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Group does not exist.'),$feed));
-                } else {
-                    return true;
+                    throw new ClientException(sprintf(_m('Invalid hub.topic "%s". Local_group does not exist.'),$feed));
                 }
+                return true;
             }
-        } else if (preg_match('!/(\d+)/lists/(\d+)/statuses\.atom$!', $feed, $matches)) {
+            common_debug("Feed was not recognized by any local User or Group Atom feed URLs: {$feed}");
+            return false;
+        }
+
+        // Profile lists are unique per user, so we need both IDs
+        if (preg_match('!/(\d+)/lists/(\d+)/statuses\.atom$!', $feed, $matches)) {
             $user = $matches[1];
             $id = $matches[2];
             $params = array('user' => $user, 'id' => $id, 'format' => 'atom');
-            $listFeed = common_local_url('ApiTimelineList', $params);
 
-            if ($feed == $listFeed) {
+            // Double-check against locally generated URLs
+            switch ($feed) {
+            case common_local_url('ApiTimelineList', $params):
                 $list = Profile_list::getKV('id', $id);
                 $user = User::getKV('id', $user);
-                if (!$list || !$user || $list->tagger != $user->id) {
+                if (!$list instanceof Profile_list || !$user instanceof User || $list->tagger != $user->id) {
                     // TRANS: Client exception. %s is a feed URL.
                     throw new ClientException(sprintf(_m('Invalid hub.topic %s; list does not exist.'),$feed));
-                } else {
-                    return true;
                 }
+                return true;
             }
-            common_log(LOG_DEBUG, "Not a user, group or people tag feed? $feed $userFeed $groupFeed $listFeed");
+            common_debug("Feed was not recognized by any local Profile_list Atom feed URL: {$feed}");
+            return false;
         }
-        common_log(LOG_DEBUG, "LOST $feed");
+
+        common_debug("Unknown feed URL structure, can't match against local user, group or profile_list: {$feed}");
         return false;
     }
 
index 57c056f5fbd7f3b29849221d56b40ffc65ab4e23..adc1aa11be6506eb9041a85db5b1924c53180131 100644 (file)
@@ -86,7 +86,7 @@ class FeedSub extends Managed_DataObject
                 'sub_state' => array('type' => 'enum("subscribe","active","unsubscribe","inactive","nohub")', 'not null' => true, 'description' => 'subscription state'),
                 'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'),
                 'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'),
-                'last_update' => array('type' => 'datetime', 'not null' => true, 'description' => 'when this record was last updated'),
+                'last_update' => array('type' => 'datetime', 'description' => 'when this record was last updated'),
                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
             ),
index 30c32ac1aa2b18c1089063a99f0a0ae8a91fa9b8..96c6986cdf7923b7446e25b43f98179baeec2831 100644 (file)
@@ -58,7 +58,7 @@ class HubSub extends Managed_DataObject
                 'topic' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'HubSub topic'),
                 'callback' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'HubSub callback'),
                 'secret' => array('type' => 'text', 'description' => 'HubSub stored secret'),
-                'lease' => array('type' => 'int', 'not null' => true, 'description' => 'HubSub leasetime'),
+                'lease' => array('type' => 'int', 'description' => 'HubSub leasetime'),
                 'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'),
                 'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'),
                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),