Fix code style

This commit is contained in:
Art4 2025-01-13 13:31:54 +00:00
parent d4697a17a3
commit 0e59dba914
102 changed files with 3038 additions and 2764 deletions

View file

@ -287,8 +287,8 @@ class BaseApi extends BaseModule
$prev_request = $next_request = $request;
if ($asDate) {
$max_date = self::$boundaries['max'];
$min_date = self::$boundaries['min'];
$max_date = self::$boundaries['max'];
$min_date = self::$boundaries['min'];
$prev_request['min_id'] = $max_date->format(DateTimeFormat::JSON);
$next_request['max_id'] = $min_date->format(DateTimeFormat::JSON);
} else {
@ -432,48 +432,48 @@ class BaseApi extends BaseModule
// Check for throttling (maximum posts per day, week and month)
$throttle_day = DI::config()->get('system', 'throttle_limit_day');
if ($throttle_day > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24 * 60 * 60);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$posts_day = Post::countThread($condition);
if ($posts_day > $throttle_day) {
$this->logger->notice('Daily posting limit reached', ['uid' => $uid, 'posts' => $posts_day, 'limit' => $throttle_day]);
$error = $this->t('Too Many Requests');
$error = $this->t('Too Many Requests');
$error_description = $this->tt("Daily posting limit of %d post reached. The post was rejected.", "Daily posting limit of %d posts reached. The post was rejected.", $throttle_day);
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$this->jsonError(429, $errorobj->toArray());
}
}
$throttle_week = DI::config()->get('system', 'throttle_limit_week');
if ($throttle_week > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24 * 60 * 60 * 7);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$posts_week = Post::countThread($condition);
if ($posts_week > $throttle_week) {
$this->logger->notice('Weekly posting limit reached', ['uid' => $uid, 'posts' => $posts_week, 'limit' => $throttle_week]);
$error = $this->t('Too Many Requests');
$error = $this->t('Too Many Requests');
$error_description = $this->tt("Weekly posting limit of %d post reached. The post was rejected.", "Weekly posting limit of %d posts reached. The post was rejected.", $throttle_week);
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$this->jsonError(429, $errorobj->toArray());
}
}
$throttle_month = DI::config()->get('system', 'throttle_limit_month');
if ($throttle_month > 0) {
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24 * 60 * 60 * 30);
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$condition = ["`gravity` = ? AND `uid` = ? AND `wall` AND `received` > ?", Item::GRAVITY_PARENT, $uid, $datefrom];
$posts_month = Post::countThread($condition);
if ($posts_month > $throttle_month) {
$this->logger->notice('Monthly posting limit reached', ['uid' => $uid, 'posts' => $posts_month, 'limit' => $throttle_month]);
$error = $this->t('Too Many Requests');
$error = $this->t('Too Many Requests');
$error_description = $this->tt('Monthly posting limit of %d post reached. The post was rejected.', 'Monthly posting limit of %d posts reached. The post was rejected.', $throttle_month);
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$errorobj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$this->jsonError(429, $errorobj->toArray());
}
}