Merge pull request #4539 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-07-14 01:50:53 -06:00 committed by GitHub
commit 57582b1b2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1248 additions and 1179 deletions

View file

@ -26,6 +26,13 @@
- Update ComposeModal.vue, fix scroll issue and dont hide scrollbar ([2d959fb3](https://github.com/pixelfed/pixelfed/commit/2d959fb3))
- Update AccountImport, add select first 100 posts button ([625a76a5](https://github.com/pixelfed/pixelfed/commit/625a76a5))
- Update ApiV1Controller, add include_reblogs attribute to home timeline ([37fd0342](https://github.com/pixelfed/pixelfed/commit/37fd0342))
- Update rate limits, fixes #4537 ([1cc6274a](https://github.com/pixelfed/pixelfed/commit/1cc6274a))
- Update Services, use zpopmin on predis ([4b2c66f5](https://github.com/pixelfed/pixelfed/commit/4b2c66f5))
- Update Inbox, allow storing Create->Note activities without any local followers, disabled by default ([9fa6b3f7](https://github.com/pixelfed/pixelfed/commit/9fa6b3f7))
- Update AP Helpers, preserve admin unlisted state before adding to NetworkTimelineService ([0704c7e0](https://github.com/pixelfed/pixelfed/commit/0704c7e0))
- Update SearchApiV2Service, improve resolve query logic to better handle remote posts/profiles and local posts/profiles ([c61d0b91](https://github.com/pixelfed/pixelfed/commit/c61d0b91))
- Update FollowPipeline, improve follower/following count calculation ([0b515767](https://github.com/pixelfed/pixelfed/commit/0b515767))
- Update TransformImports command, increment status_count on profile model ([ba7551d8](https://github.com/pixelfed/pixelfed/commit/ba7551d8))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.8 (2023-05-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.7...v0.11.8)

View file

@ -9,6 +9,7 @@ use App\Media;
use App\Profile;
use App\Status;
use Storage;
use App\Services\AccountService;
use App\Services\MediaPathService;
use Illuminate\Support\Str;
use App\Util\Lexer\Autolink;
@ -38,7 +39,7 @@ class TransformImports extends Command
return;
}
$ips = ImportPost::whereNull('status_id')->where('skip_missing_media', '!=', true)->take(200)->get();
$ips = ImportPost::whereNull('status_id')->where('skip_missing_media', '!=', true)->take(500)->get();
if(!$ips->count()) {
return;
@ -135,6 +136,11 @@ class TransformImports extends Command
$ip->creation_id = $idk['incr'];
$ip->save();
$profile->status_count = $profile->status_count + 1;
$profile->save();
AccountService::del($profile->id);
ImportService::clearAttempts($profile->id);
ImportService::getPostCount($profile->id, true);
}

View file

@ -1621,7 +1621,7 @@ class ApiV1Controller extends Controller
$limitReached = Cache::remember($limitKey, $limitTtl, function() use($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
return $dailyLimit >= 250;
return $dailyLimit >= 1250;
});
abort_if($limitReached == true, 429);
@ -1826,7 +1826,7 @@ class ApiV1Controller extends Controller
$limitReached = Cache::remember($limitKey, $limitTtl, function() use($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
return $dailyLimit >= 250;
return $dailyLimit >= 1250;
});
abort_if($limitReached == true, 429);
@ -2838,7 +2838,7 @@ class ApiV1Controller extends Controller
->where('created_at', '>', now()->subDays(1))
->count();
return $dailyLimit >= 100;
return $dailyLimit >= 1000;
});
abort_if($limitReached == true, 429);

View file

@ -225,7 +225,7 @@ class ApiV2Controller extends Controller
$limitReached = Cache::remember($limitKey, $limitTtl, function() use($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
return $dailyLimit >= 250;
return $dailyLimit >= 1250;
});
abort_if($limitReached == true, 429);

View file

@ -98,7 +98,7 @@ class ComposeController extends Controller
$limitReached = Cache::remember($limitKey, $limitTtl, function() use($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
return $dailyLimit >= 250;
return $dailyLimit >= 1250;
});
abort_if($limitReached == true, 429);
@ -190,7 +190,7 @@ class ComposeController extends Controller
$limitReached = Cache::remember($limitKey, $limitTtl, function() use($user) {
$dailyLimit = Media::whereUserId($user->id)->where('created_at', '>', now()->subDays(1))->count();
return $dailyLimit >= 500;
return $dailyLimit >= 1500;
});
abort_if($limitReached == true, 429);
@ -499,7 +499,7 @@ class ComposeController extends Controller
->where('created_at', '>', now()->subDays(1))
->count();
return $dailyLimit >= 100;
return $dailyLimit >= 1000;
});
abort_if($limitReached == true, 429);

View file

@ -53,44 +53,24 @@ class FollowPipeline implements ShouldQueue
return;
}
if($target->domain || !$target->private_key) {
return;
}
Cache::forget('profile:following:' . $actor->id);
Cache::forget('profile:following:' . $target->id);
FollowerService::add($actor->id, $target->id);
$actorProfileSync = Cache::get(FollowerService::FOLLOWING_SYNC_KEY . $actor->id);
if(!$actorProfileSync) {
FollowServiceWarmCache::dispatch($actor->id)->onQueue('low');
} else {
if($actor->following_count) {
$actor->increment('following_count');
} else {
$count = Follower::whereProfileId($actor->id)->count();
$actor->following_count = $count;
$actor->save();
}
Cache::put(FollowerService::FOLLOWING_SYNC_KEY . $actor->id, 1, 604800);
AccountService::del($actor->id);
}
$targetProfileSync = Cache::get(FollowerService::FOLLOWERS_SYNC_KEY . $target->id);
if(!$targetProfileSync) {
FollowServiceWarmCache::dispatch($target->id)->onQueue('low');
} else {
if($target->followers_count) {
$target->increment('followers_count');
} else {
$count = Follower::whereFollowingId($target->id)->count();
$target->followers_count = $count;
$target->save();
}
Cache::put(FollowerService::FOLLOWERS_SYNC_KEY . $target->id, 1, 604800);
AccountService::del($target->id);
}
if($target->domain || !$target->private_key) {
return;
}
try {
$notification = new Notification();

View file

@ -24,10 +24,8 @@ class LikeService {
public static function setAdd($profileId, $statusId)
{
if(self::setCount($profileId) > 400) {
if(config('database.redis.client') === 'phpredis') {
Redis::zpopmin(self::CACHE_SET_KEY . $profileId);
}
}
return Redis::zadd(self::CACHE_SET_KEY . $profileId, $statusId, $statusId);
}

View file

@ -49,10 +49,8 @@ class NetworkTimelineService
public static function add($val)
{
if(self::count() > config('instance.timeline.network.cache_dropoff')) {
if(config('database.redis.client') === 'phpredis') {
Redis::zpopmin(self::CACHE_KEY);
}
}
return Redis::zadd(self::CACHE_KEY, $val, $val);
}

View file

@ -49,10 +49,8 @@ class PublicTimelineService {
public static function add($val)
{
if(self::count() > 400) {
if(config('database.redis.client') === 'phpredis') {
Redis::zpopmin(self::CACHE_KEY);
}
}
return Redis::zadd(self::CACHE_KEY, $val, $val);
}

View file

@ -179,8 +179,10 @@ class SearchApiV2Service
return $default;
}
if(Helpers::validateLocalUrl($query)) {
if(Str::contains($query, '/p/')) {
if(Str::contains($query, '/p/') || Str::contains($query, 'i/web/post/')) {
return $this->resolveLocalStatus();
} else if(Str::contains($query, 'i/web/profile/')) {
return $this->resolveLocalProfileId();
} else {
return $this->resolveLocalProfile();
}
@ -217,6 +219,14 @@ class SearchApiV2Service
}
}
if($sid = Status::whereUri($query)->first()) {
$s = StatusService::get($sid->id, false);
if(in_array($s['visibility'], ['public', 'unlisted'])) {
$default['statuses'][] = $s;
return $default;
}
}
try {
$res = ActivityPubFetchService::get($query);
$banned = InstanceService::getBannedDomains();
@ -238,11 +248,14 @@ class SearchApiV2Service
return $default;
}
$note = $mastodonMode ?
StatusService::getMastodon($obj['id']) :
StatusService::get($obj['id']);
StatusService::getMastodon($obj['id'], false) :
StatusService::get($obj['id'], false);
if(!$note) {
return $default;
}
if(!isset($note['visibility']) || !in_array($note['visibility'], ['public', 'unlisted'])) {
return $default;
}
$default['statuses'][] = $note;
return $default;
break;
@ -256,8 +269,8 @@ class SearchApiV2Service
return $default;
}
$default['accounts'][] = $mastodonMode ?
AccountService::getMastodon($obj['id']) :
AccountService::get($obj['id']);
AccountService::getMastodon($obj['id'], true) :
AccountService::get($obj['id'], true);
return $default;
break;
@ -285,9 +298,9 @@ class SearchApiV2Service
protected function resolveLocalStatus()
{
$query = urldecode($this->query->input('q'));
$query = last(explode('/', $query));
$status = StatusService::getMastodon($query);
if(!$status) {
$query = last(explode('/', parse_url($query, PHP_URL_PATH)));
$status = StatusService::getMastodon($query, false);
if(!$status || !in_array($status['visibility'], ['public', 'unlisted'])) {
return [
'accounts' => [],
'hashtags' => [],
@ -307,7 +320,7 @@ class SearchApiV2Service
protected function resolveLocalProfile()
{
$query = urldecode($this->query->input('q'));
$query = last(explode('/', $query));
$query = last(explode('/', parse_url($query, PHP_URL_PATH)));
$profile = Profile::whereNull('status')
->whereNull('domain')
->whereUsername($query)
@ -325,7 +338,32 @@ class SearchApiV2Service
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
return [
'accounts' => $fractal->createData($resource)->toArray(),
'accounts' => [$fractal->createData($resource)->toArray()],
'hashtags' => [],
'statuses' => []
];
}
protected function resolveLocalProfileId()
{
$query = urldecode($this->query->input('q'));
$query = last(explode('/', parse_url($query, PHP_URL_PATH)));
$profile = Profile::whereNull('status')
->find($query);
if(!$profile) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => []
];
}
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
return [
'accounts' => [$fractal->createData($resource)->toArray()],
'hashtags' => [],
'statuses' => []
];

View file

@ -466,12 +466,19 @@ class Helpers {
$scope = self::getScope($activity, $url);
$cw = self::getSensitive($activity, $url);
$pid = is_object($profile) ? $profile->id : (is_array($profile) ? $profile['id'] : null);
$isUnlisted = is_object($profile) ? $profile->unlisted : (is_array($profile) ? $profile['unlisted'] : false);
$commentsDisabled = isset($activity['commentsEnabled']) ? !boolval($activity['commentsEnabled']) : false;
if(!$pid) {
return;
}
if($scope == 'public') {
if($isUnlisted == true) {
$scope = 'unlisted';
}
}
$status = Status::updateOrCreate(
[
'uri' => $url
@ -519,9 +526,11 @@ class Helpers {
->values()
->toArray();
if(!in_array($urlDomain, $filteredDomains)) {
if(!$isUnlisted) {
NetworkTimelineService::add($status->id);
}
}
}
IncrementPostCount::dispatch($pid)->onQueue('low');

View file

@ -281,7 +281,8 @@ class Inbox
}
if($actor->followers_count == 0) {
if(FollowerService::followerCount($actor->id, true) == 0) {
if(config('federation.activitypub.ingest.store_notes_without_followers')) {
} else if(FollowerService::followerCount($actor->id, true) == 0) {
return;
}
}

75
composer.lock generated
View file

@ -62,16 +62,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.275.5",
"version": "3.275.7",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "d46961b82e857f77059c0c78160719ecb26f6cc6"
"reference": "54dcef3349c81b46c0f5f6e54b5f9bfb5db19903"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d46961b82e857f77059c0c78160719ecb26f6cc6",
"reference": "d46961b82e857f77059c0c78160719ecb26f6cc6",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/54dcef3349c81b46c0f5f6e54b5f9bfb5db19903",
"reference": "54dcef3349c81b46c0f5f6e54b5f9bfb5db19903",
"shasum": ""
},
"require": {
@ -151,9 +151,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.275.5"
"source": "https://github.com/aws/aws-sdk-php/tree/3.275.7"
},
"time": "2023-07-07T18:20:11+00:00"
"time": "2023-07-13T18:21:04+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -2357,16 +2357,16 @@
},
{
"name": "laravel/framework",
"version": "v10.14.1",
"version": "v10.15.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "6f89a2b74b232d8bf2e1d9ed87e311841263dfcb"
"reference": "c7599dc92e04532824bafbd226c2936ce6a905b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/6f89a2b74b232d8bf2e1d9ed87e311841263dfcb",
"reference": "6f89a2b74b232d8bf2e1d9ed87e311841263dfcb",
"url": "https://api.github.com/repos/laravel/framework/zipball/c7599dc92e04532824bafbd226c2936ce6a905b8",
"reference": "c7599dc92e04532824bafbd226c2936ce6a905b8",
"shasum": ""
},
"require": {
@ -2553,7 +2553,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2023-06-28T14:25:16+00:00"
"time": "2023-07-11T13:43:52+00:00"
},
{
"name": "laravel/helpers",
@ -2613,16 +2613,16 @@
},
{
"name": "laravel/horizon",
"version": "v5.17.0",
"version": "v5.18.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/horizon.git",
"reference": "569c7154033679a1ca05b43bfa640cc60aa3b37b"
"reference": "b14498a09af826035e46ae8d6b013d0ec849bdb7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/569c7154033679a1ca05b43bfa640cc60aa3b37b",
"reference": "569c7154033679a1ca05b43bfa640cc60aa3b37b",
"url": "https://api.github.com/repos/laravel/horizon/zipball/b14498a09af826035e46ae8d6b013d0ec849bdb7",
"reference": "b14498a09af826035e46ae8d6b013d0ec849bdb7",
"shasum": ""
},
"require": {
@ -2685,9 +2685,9 @@
],
"support": {
"issues": "https://github.com/laravel/horizon/issues",
"source": "https://github.com/laravel/horizon/tree/v5.17.0"
"source": "https://github.com/laravel/horizon/tree/v5.18.0"
},
"time": "2023-06-13T20:49:30+00:00"
"time": "2023-06-30T15:11:51+00:00"
},
{
"name": "laravel/passport",
@ -6651,23 +6651,24 @@
},
{
"name": "react/promise",
"version": "v2.10.0",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/reactphp/promise.git",
"reference": "f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38"
"reference": "c86753c76fd3be465d93b308f18d189f01a22be4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38",
"reference": "f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38",
"url": "https://api.github.com/repos/reactphp/promise/zipball/c86753c76fd3be465d93b308f18d189f01a22be4",
"reference": "c86753c76fd3be465d93b308f18d189f01a22be4",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.36"
"phpstan/phpstan": "1.10.20 || 1.4.10",
"phpunit/phpunit": "^9.5 || ^7.5"
},
"type": "library",
"autoload": {
@ -6711,7 +6712,7 @@
],
"support": {
"issues": "https://github.com/reactphp/promise/issues",
"source": "https://github.com/reactphp/promise/tree/v2.10.0"
"source": "https://github.com/reactphp/promise/tree/v3.0.0"
},
"funding": [
{
@ -6719,7 +6720,7 @@
"type": "open_collective"
}
],
"time": "2023-05-02T15:15:43+00:00"
"time": "2023-07-11T16:12:49+00:00"
},
{
"name": "react/socket",
@ -10920,16 +10921,16 @@
},
{
"name": "filp/whoops",
"version": "2.15.2",
"version": "2.15.3",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
"reference": "aac9304c5ed61bf7b1b7a6064bf9806ab842ce73"
"reference": "c83e88a30524f9360b11f585f71e6b17313b7187"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/aac9304c5ed61bf7b1b7a6064bf9806ab842ce73",
"reference": "aac9304c5ed61bf7b1b7a6064bf9806ab842ce73",
"url": "https://api.github.com/repos/filp/whoops/zipball/c83e88a30524f9360b11f585f71e6b17313b7187",
"reference": "c83e88a30524f9360b11f585f71e6b17313b7187",
"shasum": ""
},
"require": {
@ -10979,7 +10980,7 @@
],
"support": {
"issues": "https://github.com/filp/whoops/issues",
"source": "https://github.com/filp/whoops/tree/2.15.2"
"source": "https://github.com/filp/whoops/tree/2.15.3"
},
"funding": [
{
@ -10987,7 +10988,7 @@
"type": "github"
}
],
"time": "2023-04-12T12:00:00+00:00"
"time": "2023-07-13T12:00:00+00:00"
},
{
"name": "hamcrest/hamcrest-php",
@ -11101,16 +11102,16 @@
},
{
"name": "laravel/telescope",
"version": "v4.15.0",
"version": "v4.15.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/telescope.git",
"reference": "572a19b4c9b09295848de9a2352737a756a0fb05"
"reference": "5d74ae4c9f269b756d7877ad1527770c59846e14"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/telescope/zipball/572a19b4c9b09295848de9a2352737a756a0fb05",
"reference": "572a19b4c9b09295848de9a2352737a756a0fb05",
"url": "https://api.github.com/repos/laravel/telescope/zipball/5d74ae4c9f269b756d7877ad1527770c59846e14",
"reference": "5d74ae4c9f269b756d7877ad1527770c59846e14",
"shasum": ""
},
"require": {
@ -11166,9 +11167,9 @@
],
"support": {
"issues": "https://github.com/laravel/telescope/issues",
"source": "https://github.com/laravel/telescope/tree/v4.15.0"
"source": "https://github.com/laravel/telescope/tree/v4.15.2"
},
"time": "2023-06-08T13:57:22+00:00"
"time": "2023-07-13T20:06:27+00:00"
},
{
"name": "mockery/mockery",

View file

@ -25,7 +25,11 @@ return [
'enabled' => env('AP_LOGGER_ENABLED', false),
'driver' => 'log'
]
]
],
'ingest' => [
'store_notes_without_followers' => env('AP_INGEST_STORE_NOTES_WITHOUT_FOLLOWERS', false),
],
],
'atom' => [
@ -52,6 +56,5 @@ return [
// max size in bytes, default is 2mb
'max_size' => env('CUSTOM_EMOJI_MAX_SIZE', 2000000),
]
],
];

View file

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('followers', function (Blueprint $table) {
$table->boolean('show_reblogs')->default(true)->index()->after('local_following');
$table->boolean('notify')->default(false)->index()->after('show_reblogs');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('followers', function (Blueprint $table) {
$table->dropColumn('show_reblogs');
$table->dropColumn('notify');
});
}
};