]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'nightly' into 'nightly'
authormmn <mmn@hethane.se>
Tue, 5 Jan 2016 23:53:08 +0000 (23:53 +0000)
committermmn <mmn@hethane.se>
Tue, 5 Jan 2016 23:53:08 +0000 (23:53 +0000)
only count post-notices (i.e. don't include activity-notices in statuses_count in the API)

See merge request !73

14 files changed:
actions/apilistmemberships.php
actions/apilists.php
actions/newnotice.php
actions/peopletagautocomplete.php
actions/peopletagsbyuser.php
actions/peopletagsforuser.php
classes/File_redirection.php
classes/Notice.php
classes/Profile.php
lib/httpclient.php
lib/listsnav.php
lib/peopletagsforusersection.php
lib/util.php
plugins/OpenID/OpenIDPlugin.php

index 04c771536306fa4779ea13165e24e98a944c716b..bf7f0e84d81a4e72a288f448ab06de45d95adfde 100644 (file)
@@ -115,11 +115,10 @@ class ApiListMembershipsAction extends ApiBareAuthAction
 
     function getLists()
     {
-        $profile = $this->target;
-        $fn = array($profile, 'getOtherTags');
+        $fn = array($this->target, 'getOtherTags');
 
         # 20 lists
         list($this->lists, $this->next_cursor, $this->prev_cursor) =
-                Profile_list::getAtCursor($fn, array($this->auth_user), $this->cursor, 20);
+                Profile_list::getAtCursor($fn, array($this->scoped), $this->cursor, 20);
     }
 }
index 4134577e099d27a2b4c9aa9368df8aba5f466e24..0b241638ad6c8fd61616efb2fdfd2ab8691c02f7 100644 (file)
@@ -185,7 +185,7 @@ class ApiListsAction extends ApiBareAuthAction
 
         list($this->lists,
              $this->next_cursor,
-             $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->auth_user), $cursor, $count);
+             $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->scoped), $cursor, $count);
     }
 
     function isReadOnly($args)
index 17499312fbcbd45ea1157cba0e6a87010d468d5a..c4b6bfa554a9c604af56c04cc10f66c469165cd9 100644 (file)
@@ -131,6 +131,17 @@ class NewnoticeAction extends FormAction
 
         $content = $this->scoped->shortenLinks($content);
 
+        // Reject notice if it is too long (without the HTML)
+        // Should we do this before or after the upload attachment link? I think before...
+        if (Notice::contentTooLong($content)) {
+            // TRANS: Client error displayed when the parameter "status" is missing.
+            // TRANS: %d is the maximum number of character for a notice.
+            throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.',
+                                                 'That\'s too long. Maximum notice size is %d characters.',
+                                                 Notice::maxContent()),
+                                              Notice::maxContent()));
+        }
+
         $upload = null;
         try {
             // throws exception on failure
@@ -140,15 +151,7 @@ class NewnoticeAction extends FormAction
             }
             Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
 
-            if (Notice::contentTooLong($content)) {
-                $upload->delete();
-                // TRANS: Client error displayed exceeding the maximum notice length.
-                // TRANS: %d is the maximum length for a notice.
-                $this->clientError(sprintf(_m('Maximum notice size is %d character, including attachment URL.',
-                                              'Maximum notice size is %d characters, including attachment URL.',
-                                              Notice::maxContent()),
-                                           Notice::maxContent()));
-            }
+            // We could check content length here if the URL was added, but I'll just let it slide for now...
 
             $act->enclosures[] = $upload->getEnclosure();
         } catch (NoUploadedMediaException $e) {
index 86d63545dcb0b4ed2aa4040e78aef8e8ebf9899e..c239c03bfb0d3d9c1c4321ba798b1911f7396b42 100644 (file)
@@ -68,7 +68,7 @@ class PeopletagautocompleteAction extends Action
         }
 
         $profile = $this->user->getProfile();
-        $tags = $profile->getLists(common_current_user());
+        $tags = $profile->getLists($this->scoped);
 
         $this->tags = array();
         while ($tags->fetch()) {
index 8b3a91917a5f0611b7fbebbc8b847edba393e67f..4a04ea2fbbf8c0d4e1f703e4d6d29cac96896087 100644 (file)
@@ -116,7 +116,7 @@ class PeopletagsbyuserAction extends Action
 
         $user = common_current_user();
         if ($this->arg('public')) {
-            $this->tags = $this->tagger->getLists(false, $offset, $limit);
+            $this->tags = $this->tagger->getLists(null, $offset, $limit);
         } else if ($this->arg('private')) {
             if (empty($user)) {
                 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
@@ -130,7 +130,7 @@ class PeopletagsbyuserAction extends Action
                 $this->clientError(_('You cannot view others\' private lists'), 403);
             }
         } else {
-            $this->tags = $this->tagger->getLists(common_current_user(), $offset, $limit);
+            $this->tags = $this->tagger->getLists($this->scoped, $offset, $limit);
         }
         return true;
     }
index 827b284d5c3acf567cf550f5afdae99ed06c721b..7679be0b862ad2ec74f3c32d58e255ee6c41c040 100644 (file)
@@ -126,7 +126,7 @@ class PeopletagsforuserAction extends Action
         $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
         $limit  = PEOPLETAGS_PER_PAGE + 1;
 
-        $ptags = $this->tagged->getOtherTags(common_current_user(), $offset, $limit);
+        $ptags = $this->tagged->getOtherTags($this->scoped, $offset, $limit);
 
         $pl = new PeopletagList($ptags, $this);
         $cnt = $pl->show();
index a324deaa5d59fbe1ca07e088e232c1e6e7594dd6..03df3de1b1153e8e8a496b07eaeb8e1c08f0134b 100644 (file)
@@ -195,6 +195,7 @@ class File_redirection extends Managed_DataObject
 
             $redir->httpcode = $redir_info['code'];
             $redir->redirections = intval($redir_info['redirects']);
+            $redir->redir_url = $redir_info['url'];            
             $redir->file = new File();
             $redir->file->url = $redir_info['url'];
             $redir->file->mimetype = $redir_info['type'];
@@ -396,4 +397,4 @@ class File_redirection extends Managed_DataObject
 
         return $this->file;
     }
-}
+}
\ No newline at end of file
index 1afc6d09772d583df574ec4395f0053e97bc16d5..513888d2450f3e1a738fba7ab93c287ff03837e9 100644 (file)
@@ -825,17 +825,6 @@ class Notice extends Managed_DataObject
         $stored->rendered = $actor->isLocal() ? $content : common_purify($content);
         $stored->content = common_strip_html($stored->rendered);
 
-        // Reject notice if it is too long (without the HTML)
-        // FIXME: Reject if too short (empty) too? But we have to pass the 
-        if ($actor->isLocal() && Notice::contentTooLong($stored->content)) {
-            // TRANS: Client error displayed when the parameter "status" is missing.
-            // TRANS: %d is the maximum number of character for a notice.
-            throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.',
-                                                 'That\'s too long. Maximum notice size is %d characters.',
-                                                 Notice::maxContent()),
-                                              Notice::maxContent()));
-        }
-
         // Maybe a missing act-time should be fatal if the actor is not local?
         if (!empty($act->time)) {
             $stored->created = common_sql_date($act->time);
index 620772b0a409178dfd55e59b8c5d797eb20907cf..00701bc7482b5043cf6b50b9409a81c6d06d51f0 100644 (file)
@@ -381,7 +381,7 @@ class Profile extends Managed_DataObject
         return false;
     }
 
-    function getLists($auth_user, $offset=0, $limit=null, $since_id=0, $max_id=0)
+    function getLists(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
     {
         $ids = array();
 
@@ -421,9 +421,7 @@ class Profile extends Managed_DataObject
             self::cacheSet($keypart, implode(',', $ids));
         }
 
-        $showPrivate = (($auth_user instanceof User ||
-                            $auth_user instanceof Profile) &&
-                        $auth_user->id === $this->id);
+        $showPrivate = $this->sameAs($scoped);
 
         $lists = array();
 
@@ -446,7 +444,7 @@ class Profile extends Managed_DataObject
     /**
      * Get tags that other people put on this profile, in reverse-chron order
      *
-     * @param (Profile|User) $auth_user  Authorized user (used for privacy)
+     * @param Profile        $scoped     User we are requesting as
      * @param int            $offset     Offset from latest
      * @param int            $limit      Max number to get
      * @param datetime       $since_id   max date
@@ -455,7 +453,7 @@ class Profile extends Managed_DataObject
      * @return Profile_list resulting lists
      */
 
-    function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
+    function getOtherTags(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
     {
         $list = new Profile_list();
 
@@ -467,11 +465,11 @@ class Profile extends Managed_DataObject
                        $this->id);
 
 
-        if ($auth_user instanceof User || $auth_user instanceof Profile) {
+        if (!is_null($scoped)) {
             $qry .= sprintf('AND ( ( profile_list.private = false ) ' .
                             'OR ( profile_list.tagger = %d AND ' .
                             'profile_list.private = true ) )',
-                            $auth_user->id);
+                            $scoped->getID());
         } else {
             $qry .= 'AND profile_list.private = 0 ';
         }
@@ -1697,4 +1695,4 @@ class Profile extends Managed_DataObject
     {
         return $this->getUser()->getConnectedApps($offset, $limit);
     }
-}
\ No newline at end of file
+}
index 4b854914c929ac0dd54d3f7787fc4556e5e90050..b386ce39875e991d08ed5fc0db4deaf2a5b7039b 100644 (file)
@@ -80,7 +80,7 @@ class GNUsocial_HTTPResponse extends HTTP_Request2_Response
      */
     function getUrl()
     {
-        return $this->url;
+        return $this->effectiveUrl;
     }
 
     /**
@@ -360,4 +360,4 @@ class HTTPClient extends HTTP_Request2
         } while ($maxRedirs);
         return new GNUsocial_HTTPResponse($response, $this->getUrl(), $redirs);
     }
-}
+}
\ No newline at end of file
index d550233ef5810864ee482df053c4b4b68f2e1c22..71e994094cbadde9870c5a9953d4db857f1f35de 100644 (file)
@@ -49,9 +49,7 @@ class ListsNav extends MoreMenu
         parent::__construct($out);
         $this->profile = $profile;
 
-        $user = common_current_user();
-
-        $this->lists = $profile->getLists($user);
+        $this->lists = $profile->getLists(Profile::current());
     }
 
     function tag()
index 37f46b850d128c5b83d4430b5a775c86c154c27b..fa5ec310330fc4dc08681a8b6c0140406609281e 100644 (file)
@@ -54,8 +54,7 @@ class PeopletagsForUserSection extends PeopletagSection
         $limit = PEOPLETAGS_PER_SECTION+1;
         $offset = 0;
 
-        $auth_user = common_current_user();
-        $ptags = $this->profile->getOtherTags($auth_user, $offset, $limit);
+        $ptags = $this->profile->getOtherTags(Profile::current(), $offset, $limit);
 
         return $ptags;
     }
index 3b5bb2de08aa2dde81822e7fd27d2b49b52ab7a3..fd903d5505a2db28a60f5f277489742516236b93 100644 (file)
@@ -980,10 +980,16 @@ function common_linkify($url) {
     } else {
         $canon = File_redirection::_canonUrl($url);
         $longurl_data = File_redirection::where($canon, common_config('attachments', 'process_links'));
-        $longurl = $longurl_data->url;
+        
+        if(isset($longurl_data->redir_url)) {
+                       $longurl = $longurl_data->redir_url;
+        } else {
+            // e.g. local files
+               $longurl = $longurl_data->url;
+        }
     }
-
-    $attrs = array('href' => $canon, 'title' => $longurl);
+    
+    $attrs = array('href' => $longurl, 'title' => $longurl);
 
     $is_attachment = false;
     $attachment_id = null;
@@ -2430,4 +2436,4 @@ function html_sprintf()
         $args[$i] = htmlspecialchars($args[$i]);
     }
     return call_user_func_array('sprintf', $args);
-}
+}
\ No newline at end of file
index 2e9ada98064e3b36ae0d7457d98bfd3322c59488..4e5a0bfe0cb0068799a52a9a76879cda747e879d 100644 (file)
@@ -414,7 +414,7 @@ class OpenIDPlugin extends Plugin
      */
     function onRedirectToLogin($action, $user)
     {
-        if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
+        if (common_config('site', 'openidonly') || (!empty($user) && User_openid::hasOpenID($user->id))) {
             common_redirect(common_local_url('openidlogin'), 303);
         }
         return true;