1
0
Fork 0

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

@ -17,91 +17,71 @@ use App\Services\FollowerService;
class FollowPipeline implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $follower;
protected $follower;
/**
* Delete the job if its models no longer exist.
*
* @var bool
*/
public $deleteWhenMissingModels = true;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($follower)
{
$this->follower = $follower;
}
/**
* Delete the job if its models no longer exist.
*
* @var bool
*/
public $deleteWhenMissingModels = true;
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$follower = $this->follower;
$actor = $follower->actor;
$target = $follower->target;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($follower)
{
$this->follower = $follower;
}
if(!$actor || !$target) {
return;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$follower = $this->follower;
$actor = $follower->actor;
$target = $follower->target;
Cache::forget('profile:following:' . $actor->id);
Cache::forget('profile:following:' . $target->id);
if(!$actor || !$target) {
return;
}
FollowerService::add($actor->id, $target->id);
if($target->domain || !$target->private_key) {
return;
}
$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);
}
Cache::forget('profile:following:' . $actor->id);
Cache::forget('profile:following:' . $target->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);
}
FollowerService::add($actor->id, $target->id);
if($target->domain || !$target->private_key) {
return;
}
$count = Follower::whereProfileId($actor->id)->count();
$actor->following_count = $count;
$actor->save();
AccountService::del($actor->id);
try {
$notification = new Notification();
$notification->profile_id = $target->id;
$notification->actor_id = $actor->id;
$notification->action = 'follow';
$notification->item_id = $target->id;
$notification->item_type = "App\Profile";
$notification->save();
} catch (Exception $e) {
Log::error($e);
}
}
$count = Follower::whereFollowingId($target->id)->count();
$target->followers_count = $count;
$target->save();
AccountService::del($target->id);
try {
$notification = new Notification();
$notification->profile_id = $target->id;
$notification->actor_id = $actor->id;
$notification->action = 'follow';
$notification->item_id = $target->id;
$notification->item_type = "App\Profile";
$notification->save();
} catch (Exception $e) {
Log::error($e);
}
}
}

View File

@ -24,9 +24,7 @@ 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);
}
Redis::zpopmin(self::CACHE_SET_KEY . $profileId);
}
return Redis::zadd(self::CACHE_SET_KEY . $profileId, $statusId, $statusId);

View File

@ -49,9 +49,7 @@ 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);
}
Redis::zpopmin(self::CACHE_KEY);
}
return Redis::zadd(self::CACHE_KEY, $val, $val);

View File

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

View File

@ -18,317 +18,355 @@ use App\Services\StatusService;
class SearchApiV2Service
{
private $query;
static $mastodonMode = false;
private $query;
static $mastodonMode = false;
public static function query($query, $mastodonMode = false)
{
self::$mastodonMode = $mastodonMode;
return (new self)->run($query);
}
public static function query($query, $mastodonMode = false)
{
self::$mastodonMode = $mastodonMode;
return (new self)->run($query);
}
protected function run($query)
{
$this->query = $query;
$q = urldecode($query->input('q'));
protected function run($query)
{
$this->query = $query;
$q = urldecode($query->input('q'));
if($query->has('resolve') &&
( Str::startsWith($q, 'https://') ||
Str::substrCount($q, '@') >= 1)
) {
return $this->resolveQuery();
}
if($query->has('resolve') &&
( Str::startsWith($q, 'https://') ||
Str::substrCount($q, '@') >= 1)
) {
return $this->resolveQuery();
}
if($query->has('type')) {
switch ($query->input('type')) {
case 'accounts':
return [
'accounts' => $this->accounts(),
'hashtags' => [],
'statuses' => []
];
break;
case 'hashtags':
return [
'accounts' => [],
'hashtags' => $this->hashtags(),
'statuses' => []
];
break;
case 'statuses':
return [
'accounts' => [],
'hashtags' => [],
'statuses' => $this->statuses()
];
break;
}
}
if($query->has('type')) {
switch ($query->input('type')) {
case 'accounts':
return [
'accounts' => $this->accounts(),
'hashtags' => [],
'statuses' => []
];
break;
case 'hashtags':
return [
'accounts' => [],
'hashtags' => $this->hashtags(),
'statuses' => []
];
break;
case 'statuses':
return [
'accounts' => [],
'hashtags' => [],
'statuses' => $this->statuses()
];
break;
}
}
if($query->has('account_id')) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => $this->statusesById()
];
}
if($query->has('account_id')) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => $this->statusesById()
];
}
return [
'accounts' => $this->accounts(),
'hashtags' => $this->hashtags(),
'statuses' => $this->statuses()
];
}
return [
'accounts' => $this->accounts(),
'hashtags' => $this->hashtags(),
'statuses' => $this->statuses()
];
}
protected function accounts($initalQuery = false)
{
$mastodonMode = self::$mastodonMode;
$user = request()->user();
$limit = $this->query->input('limit') ?? 20;
$offset = $this->query->input('offset') ?? 0;
$rawQuery = $initalQuery ? $initalQuery : $this->query->input('q');
$query = $rawQuery . '%';
$webfingerQuery = $query;
if(Str::substrCount($rawQuery, '@') == 1 && substr($rawQuery, 0, 1) !== '@') {
$query = '@' . $query;
}
if(substr($webfingerQuery, 0, 1) !== '@') {
$webfingerQuery = '@' . $webfingerQuery;
}
$banned = InstanceService::getBannedDomains();
$operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
$results = Profile::select('username', 'id', 'followers_count', 'domain')
->where('username', $operator, $query)
->orWhere('webfinger', $operator, $webfingerQuery)
->orderByDesc('profiles.followers_count')
->offset($offset)
->limit($limit)
->get()
->filter(function($profile) use ($banned) {
return in_array($profile->domain, $banned) == false;
})
->map(function($res) use($mastodonMode) {
return $mastodonMode ?
AccountService::getMastodon($res['id']) :
AccountService::get($res['id']);
})
->filter(function($account) {
return $account && isset($account['id']);
})
->values();
protected function accounts($initalQuery = false)
{
$mastodonMode = self::$mastodonMode;
$user = request()->user();
$limit = $this->query->input('limit') ?? 20;
$offset = $this->query->input('offset') ?? 0;
$rawQuery = $initalQuery ? $initalQuery : $this->query->input('q');
$query = $rawQuery . '%';
$webfingerQuery = $query;
if(Str::substrCount($rawQuery, '@') == 1 && substr($rawQuery, 0, 1) !== '@') {
$query = '@' . $query;
}
if(substr($webfingerQuery, 0, 1) !== '@') {
$webfingerQuery = '@' . $webfingerQuery;
}
$banned = InstanceService::getBannedDomains();
$operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
$results = Profile::select('username', 'id', 'followers_count', 'domain')
->where('username', $operator, $query)
->orWhere('webfinger', $operator, $webfingerQuery)
->orderByDesc('profiles.followers_count')
->offset($offset)
->limit($limit)
->get()
->filter(function($profile) use ($banned) {
return in_array($profile->domain, $banned) == false;
})
->map(function($res) use($mastodonMode) {
return $mastodonMode ?
AccountService::getMastodon($res['id']) :
AccountService::get($res['id']);
})
->filter(function($account) {
return $account && isset($account['id']);
})
->values();
return $results;
}
return $results;
}
protected function hashtags()
{
$mastodonMode = self::$mastodonMode;
$q = $this->query->input('q');
$limit = $this->query->input('limit') ?? 20;
$offset = $this->query->input('offset') ?? 0;
$query = Str::startsWith($q, '#') ? '%' . substr($q, 1) . '%' : '%' . $q . '%';
$operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
return Hashtag::where('name', $operator, $query)
->orWhere('slug', $operator, $query)
->where(function($q) {
return $q->where('can_search', true)
->orWhereNull('can_search');
})
->orderByDesc('cached_count')
->offset($offset)
->limit($limit)
->get()
->map(function($tag) use($mastodonMode) {
$res = [
'name' => $tag->name,
'url' => $tag->url()
];
protected function hashtags()
{
$mastodonMode = self::$mastodonMode;
$q = $this->query->input('q');
$limit = $this->query->input('limit') ?? 20;
$offset = $this->query->input('offset') ?? 0;
$query = Str::startsWith($q, '#') ? '%' . substr($q, 1) . '%' : '%' . $q . '%';
$operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
return Hashtag::where('name', $operator, $query)
->orWhere('slug', $operator, $query)
->where(function($q) {
return $q->where('can_search', true)
->orWhereNull('can_search');
})
->orderByDesc('cached_count')
->offset($offset)
->limit($limit)
->get()
->map(function($tag) use($mastodonMode) {
$res = [
'name' => $tag->name,
'url' => $tag->url()
];
if(!$mastodonMode) {
$res['history'] = [];
$res['count'] = HashtagService::count($tag->id);
}
if(!$mastodonMode) {
$res['history'] = [];
$res['count'] = HashtagService::count($tag->id);
}
return $res;
});
}
return $res;
});
}
protected function statuses()
{
// Removed until we provide more relevent sorting/results
return [];
}
protected function statuses()
{
// Removed until we provide more relevent sorting/results
return [];
}
protected function statusesById()
{
// Removed until we provide more relevent sorting/results
return [];
}
protected function statusesById()
{
// Removed until we provide more relevent sorting/results
return [];
}
protected function resolveQuery()
{
$default = [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
$mastodonMode = self::$mastodonMode;
$query = urldecode($this->query->input('q'));
if(substr($query, 0, 1) === '@' && !Str::contains($query, '.')) {
$default['accounts'] = $this->accounts(substr($query, 1));
return $default;
}
if(Helpers::validateLocalUrl($query)) {
if(Str::contains($query, '/p/')) {
return $this->resolveLocalStatus();
} else {
return $this->resolveLocalProfile();
}
} else {
if(!Helpers::validateUrl($query) && strpos($query, '@') == -1) {
return $default;
}
protected function resolveQuery()
{
$default = [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
$mastodonMode = self::$mastodonMode;
$query = urldecode($this->query->input('q'));
if(substr($query, 0, 1) === '@' && !Str::contains($query, '.')) {
$default['accounts'] = $this->accounts(substr($query, 1));
return $default;
}
if(Helpers::validateLocalUrl($query)) {
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();
}
} else {
if(!Helpers::validateUrl($query) && strpos($query, '@') == -1) {
return $default;
}
if(!Str::startsWith($query, 'http') && Str::substrCount($query, '@') == 1 && strpos($query, '@') !== 0) {
try {
$res = WebfingerService::lookup('@' . $query, $mastodonMode);
} catch (\Exception $e) {
return $default;
}
if($res && isset($res['id'])) {
$default['accounts'][] = $res;
return $default;
} else {
return $default;
}
}
if(!Str::startsWith($query, 'http') && Str::substrCount($query, '@') == 1 && strpos($query, '@') !== 0) {
try {
$res = WebfingerService::lookup('@' . $query, $mastodonMode);
} catch (\Exception $e) {
return $default;
}
if($res && isset($res['id'])) {
$default['accounts'][] = $res;
return $default;
} else {
return $default;
}
}
if(Str::substrCount($query, '@') == 2) {
try {
$res = WebfingerService::lookup($query, $mastodonMode);
} catch (\Exception $e) {
return $default;
}
if($res && isset($res['id'])) {
$default['accounts'][] = $res;
return $default;
} else {
return $default;
}
}
if(Str::substrCount($query, '@') == 2) {
try {
$res = WebfingerService::lookup($query, $mastodonMode);
} catch (\Exception $e) {
return $default;
}
if($res && isset($res['id'])) {
$default['accounts'][] = $res;
return $default;
} else {
return $default;
}
}
try {
$res = ActivityPubFetchService::get($query);
$banned = InstanceService::getBannedDomains();
if($res) {
$json = json_decode($res, true);
if($sid = Status::whereUri($query)->first()) {
$s = StatusService::get($sid->id, false);
if(in_array($s['visibility'], ['public', 'unlisted'])) {
$default['statuses'][] = $s;
return $default;
}
}
if(!$json || !isset($json['@context']) || !isset($json['type']) || !in_array($json['type'], ['Note', 'Person'])) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
}
try {
$res = ActivityPubFetchService::get($query);
$banned = InstanceService::getBannedDomains();
if($res) {
$json = json_decode($res, true);
switch($json['type']) {
case 'Note':
$obj = Helpers::statusFetch($query);
if(!$obj || !isset($obj['id'])) {
return $default;
}
$note = $mastodonMode ?
StatusService::getMastodon($obj['id']) :
StatusService::get($obj['id']);
if(!$note) {
return $default;
}
$default['statuses'][] = $note;
return $default;
break;
if(!$json || !isset($json['@context']) || !isset($json['type']) || !in_array($json['type'], ['Note', 'Person'])) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
}
case 'Person':
$obj = Helpers::profileFetch($query);
if(!$obj) {
return $default;
}
if(in_array($obj['domain'], $banned)) {
return $default;
}
$default['accounts'][] = $mastodonMode ?
AccountService::getMastodon($obj['id']) :
AccountService::get($obj['id']);
return $default;
break;
switch($json['type']) {
case 'Note':
$obj = Helpers::statusFetch($query);
if(!$obj || !isset($obj['id'])) {
return $default;
}
$note = $mastodonMode ?
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;
default:
return [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
break;
}
}
} catch (\Exception $e) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
}
case 'Person':
$obj = Helpers::profileFetch($query);
if(!$obj) {
return $default;
}
if(in_array($obj['domain'], $banned)) {
return $default;
}
$default['accounts'][] = $mastodonMode ?
AccountService::getMastodon($obj['id'], true) :
AccountService::get($obj['id'], true);
return $default;
break;
return $default;
}
}
default:
return [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
break;
}
}
} catch (\Exception $e) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
}
protected function resolveLocalStatus()
{
$query = urldecode($this->query->input('q'));
$query = last(explode('/', $query));
$status = StatusService::getMastodon($query);
if(!$status) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => []
];
}
return $default;
}
}
$res = [
'accounts' => [],
'hashtags' => [],
'statuses' => [$status]
];
protected function resolveLocalStatus()
{
$query = urldecode($this->query->input('q'));
$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' => [],
'statuses' => []
];
}
return $res;
}
$res = [
'accounts' => [],
'hashtags' => [],
'statuses' => [$status]
];
protected function resolveLocalProfile()
{
$query = urldecode($this->query->input('q'));
$query = last(explode('/', $query));
$profile = Profile::whereNull('status')
->whereNull('domain')
->whereUsername($query)
->first();
return $res;
}
if(!$profile) {
return [
'accounts' => [],
'hashtags' => [],
'statuses' => []
];
}
protected function resolveLocalProfile()
{
$query = urldecode($this->query->input('q'));
$query = last(explode('/', parse_url($query, PHP_URL_PATH)));
$profile = Profile::whereNull('status')
->whereNull('domain')
->whereUsername($query)
->first();
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
return [
'accounts' => $fractal->createData($resource)->toArray(),
'hashtags' => [],
'statuses' => []
];
}
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' => []
];
}
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' => []
];
}
}

File diff suppressed because it is too large Load Diff

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

@ -2,56 +2,59 @@
return [
/*
|--------------------------------------------------------------------------
| ActivityPub
|--------------------------------------------------------------------------
|
| ActivityPub configuration
|
*/
'activitypub' => [
'enabled' => env('ACTIVITY_PUB', false),
'outbox' => env('AP_OUTBOX', true),
'inbox' => env('AP_INBOX', true),
'sharedInbox' => env('AP_SHAREDINBOX', true),
/*
|--------------------------------------------------------------------------
| ActivityPub
|--------------------------------------------------------------------------
|
| ActivityPub configuration
|
*/
'activitypub' => [
'enabled' => env('ACTIVITY_PUB', false),
'outbox' => env('AP_OUTBOX', true),
'inbox' => env('AP_INBOX', true),
'sharedInbox' => env('AP_SHAREDINBOX', true),
'remoteFollow' => env('AP_REMOTE_FOLLOW', true),
'remoteFollow' => env('AP_REMOTE_FOLLOW', true),
'delivery' => [
'timeout' => env('ACTIVITYPUB_DELIVERY_TIMEOUT', 30.0),
'concurrency' => env('ACTIVITYPUB_DELIVERY_CONCURRENCY', 10),
'logger' => [
'enabled' => env('AP_LOGGER_ENABLED', false),
'driver' => 'log'
]
]
],
'delivery' => [
'timeout' => env('ACTIVITYPUB_DELIVERY_TIMEOUT', 30.0),
'concurrency' => env('ACTIVITYPUB_DELIVERY_CONCURRENCY', 10),
'logger' => [
'enabled' => env('AP_LOGGER_ENABLED', false),
'driver' => 'log'
]
],
'atom' => [
'enabled' => env('ATOM_FEEDS', true),
],
'ingest' => [
'store_notes_without_followers' => env('AP_INGEST_STORE_NOTES_WITHOUT_FOLLOWERS', false),
],
],
'avatars' => [
'store_local' => env('REMOTE_AVATARS', true),
],
'atom' => [
'enabled' => env('ATOM_FEEDS', true),
],
'nodeinfo' => [
'enabled' => env('NODEINFO', true),
],
'avatars' => [
'store_local' => env('REMOTE_AVATARS', true),
],
'webfinger' => [
'enabled' => env('WEBFINGER', true)
],
'nodeinfo' => [
'enabled' => env('NODEINFO', true),
],
'network_timeline' => env('PF_NETWORK_TIMELINE', true),
'network_timeline_days_falloff' => env('PF_NETWORK_TIMELINE_DAYS_FALLOFF', 2),
'webfinger' => [
'enabled' => env('WEBFINGER', true)
],
'custom_emoji' => [
'enabled' => env('CUSTOM_EMOJI', false),
'network_timeline' => env('PF_NETWORK_TIMELINE', true),
'network_timeline_days_falloff' => env('PF_NETWORK_TIMELINE_DAYS_FALLOFF', 2),
// max size in bytes, default is 2mb
'max_size' => env('CUSTOM_EMOJI_MAX_SIZE', 2000000),
]
'custom_emoji' => [
'enabled' => env('CUSTOM_EMOJI', false),
// 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');
});
}
};