]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/BaseApi.php
Merge pull request #10962 from annando/db-doc
[friendica.git] / src / Module / BaseApi.php
index d2aa9662c184118f615c365c4cf82b22b27dd752..5b44073f3f6ce4bfee39194aa00c858517a476de 100644 (file)
@@ -75,9 +75,7 @@ class BaseApi extends BaseModule
        {
                self::checkAllowedScope(self::SCOPE_WRITE);
 
-               $a = DI::app();
-
-               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
+               if (!DI::app()->isLoggedIn()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
@@ -86,9 +84,7 @@ class BaseApi extends BaseModule
        {
                self::checkAllowedScope(self::SCOPE_WRITE);
 
-               $a = DI::app();
-
-               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
+               if (!DI::app()->isLoggedIn()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
@@ -97,9 +93,7 @@ class BaseApi extends BaseModule
        {
                self::checkAllowedScope(self::SCOPE_WRITE);
 
-               $a = DI::app();
-
-               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
+               if (!DI::app()->isLoggedIn()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
@@ -108,9 +102,7 @@ class BaseApi extends BaseModule
        {
                self::checkAllowedScope(self::SCOPE_WRITE);
 
-               $a = DI::app();
-
-               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
+               if (!DI::app()->isLoggedIn()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
@@ -294,7 +286,7 @@ class BaseApi extends BaseModule
                        $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
 
                        $condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
-                       $posts_day = Post::count($condition);
+                       $posts_day = Post::countThread($condition);
 
                        if ($posts_day > $throttle_day) {
                                Logger::info('Daily posting limit reached', ['uid' => $uid, 'posts' => $posts_day, 'limit' => $throttle_day]);
@@ -310,7 +302,7 @@ class BaseApi extends BaseModule
                        $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
 
                        $condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
-                       $posts_week = Post::count($condition);
+                       $posts_week = Post::countThread($condition);
 
                        if ($posts_week > $throttle_week) {
                                Logger::info('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]);
@@ -326,7 +318,7 @@ class BaseApi extends BaseModule
                        $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
 
                        $condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", GRAVITY_PARENT, $uid, $datefrom];
-                       $posts_month = Post::count($condition);
+                       $posts_month = Post::countThread($condition);
 
                        if ($posts_month > $throttle_month) {
                                Logger::info('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]);