Merge pull request #3430 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-05-09 02:06:23 -06:00 committed by GitHub
commit ce7339d0f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 127 additions and 21 deletions

View file

@ -125,8 +125,12 @@
- Updated CollectionController, limit unpublished collections to owner. ([a0061eb5](https://github.com/pixelfed/pixelfed/commit/a0061eb5)) - Updated CollectionController, limit unpublished collections to owner. ([a0061eb5](https://github.com/pixelfed/pixelfed/commit/a0061eb5))
- Updated AP Inbox, fixes #3332. ([f8931dc7](https://github.com/pixelfed/pixelfed/commit/f8931dc7)) - Updated AP Inbox, fixes #3332. ([f8931dc7](https://github.com/pixelfed/pixelfed/commit/f8931dc7))
- Updated AdminReportController, add account delete button. ([563817a9](https://github.com/pixelfed/pixelfed/commit/563817a9)) - Updated AdminReportController, add account delete button. ([563817a9](https://github.com/pixelfed/pixelfed/commit/563817a9))
- Updated ApiV1Controller, added /api/v2/media endpoint, fixes #3405 ([f07cc14c](https://github.com/pixelfed/pixelfed/commit/f07cc14c)) - Updated ApiV1Controller, added /api/v2/media endpoint, fixes #3405. ([f07cc14c](https://github.com/pixelfed/pixelfed/commit/f07cc14c))
- Updated AP fanout, added Content-Type and User-Agent for activity delivery ([@noellabo](https://github.com/noellabo)) ([209c125](https://github.com/pixelfed/pixelfed/commit/209c125)) - Updated AP fanout, added Content-Type and User-Agent for activity delivery. ([@noellabo](https://github.com/noellabo)) ([209c125](https://github.com/pixelfed/pixelfed/commit/209c125))
- Updated DirectMessageController to support new Metro 2.0 UI DMs. ([a4659fd2](https://github.com/pixelfed/pixelfed/commit/a4659fd2))
- Updated Like model, bump max likes per day from 100 to 200. ([71ba5fed](https://github.com/pixelfed/pixelfed/commit/71ba5fed))
- Updated HashtagService, use sorted set for followed tags. ([153eb6ba](https://github.com/pixelfed/pixelfed/commit/153eb6ba))
- Updated Discover component, fixed post side effects (fixes #3409). ([fe5a92b2](https://github.com/pixelfed/pixelfed/commit/fe5a92b2))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)

View file

@ -1061,7 +1061,7 @@ class ApiV1Controller extends Controller
abort_if( abort_if(
Like::whereProfileId($user->profile_id) Like::whereProfileId($user->profile_id)
->where('created_at', '>', now()->subDay()) ->where('created_at', '>', now()->subDay())
->count() >= 100, ->count() >= Like::MAX_PER_DAY,
429 429
); );

View file

@ -19,6 +19,8 @@ use App\Services\MediaBlocklistService;
use App\Jobs\StatusPipeline\NewStatusPipeline; use App\Jobs\StatusPipeline\NewStatusPipeline;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Util\ActivityPub\Helpers; use App\Util\ActivityPub\Helpers;
use App\Services\AccountService;
use App\Services\StatusService;
use App\Services\WebfingerService; use App\Services\WebfingerService;
use App\Models\Conversation; use App\Models\Conversation;
@ -435,8 +437,10 @@ class DirectMessageController extends Controller
->get(); ->get();
} }
$res = $res->filter(function($s) {
$res = $res->map(function($s) use ($uid){ return $s && $s->status;
})
->map(function($s) use ($uid) {
return [ return [
'id' => (string) $s->id, 'id' => (string) $s->id,
'hidden' => (bool) $s->is_hidden, 'hidden' => (bool) $s->is_hidden,
@ -449,7 +453,8 @@ class DirectMessageController extends Controller
'reportId' => (string) $s->status_id, 'reportId' => (string) $s->status_id,
'meta' => json_decode($s->meta,true) 'meta' => json_decode($s->meta,true)
]; ];
}); })
->values();
$w = [ $w = [
'id' => (string) $r->id, 'id' => (string) $r->id,
@ -458,10 +463,10 @@ class DirectMessageController extends Controller
'avatar' => $r->avatarUrl(), 'avatar' => $r->avatarUrl(),
'url' => $r->url(), 'url' => $r->url(),
'muted' => UserFilter::whereUserId($uid) 'muted' => UserFilter::whereUserId($uid)
->whereFilterableId($r->id) ->whereFilterableId($r->id)
->whereFilterableType('App\Profile') ->whereFilterableType('App\Profile')
->whereFilterType('dm.mute') ->whereFilterType('dm.mute')
->first() ? true : false, ->first() ? true : false,
'isLocal' => (bool) !$r->domain, 'isLocal' => (bool) !$r->domain,
'domain' => $r->domain, 'domain' => $r->domain,
'timeAgo' => $r->created_at->diffForHumans(null, true, true), 'timeAgo' => $r->created_at->diffForHumans(null, true, true),
@ -482,17 +487,62 @@ class DirectMessageController extends Controller
$pid = $request->user()->profile_id; $pid = $request->user()->profile_id;
$dm = DirectMessage::whereFromId($pid) $dm = DirectMessage::whereFromId($pid)
->whereStatusId($sid) ->whereStatusId($sid)
->firstOrFail(); ->firstOrFail();
$status = Status::whereProfileId($pid) $status = Status::whereProfileId($pid)
->findOrFail($dm->status_id); ->findOrFail($dm->status_id);
if($dm->recipient->domain) { $recipient = AccountService::get($dm->to_id);
if(!$recipient) {
return response('', 422);
}
if($recipient['local'] == false) {
$dmc = $dm; $dmc = $dm;
$this->remoteDelete($dmc); $this->remoteDelete($dmc);
} }
if(Conversation::whereStatusId($sid)->count()) {
$latest = DirectMessage::where(['from_id' => $dm->from_id, 'to_id' => $dm->to_id])
->orWhere(['to_id' => $dm->from_id, 'from_id' => $dm->to_id])
->latest()
->first();
if($latest->status_id == $sid) {
Conversation::where(['to_id' => $dm->from_id, 'from_id' => $dm->to_id])
->update([
'updated_at' => $latest->updated_at,
'status_id' => $latest->status_id,
'type' => $latest->type,
'is_hidden' => false
]);
Conversation::where(['to_id' => $dm->to_id, 'from_id' => $dm->from_id])
->update([
'updated_at' => $latest->updated_at,
'status_id' => $latest->status_id,
'type' => $latest->type,
'is_hidden' => false
]);
} else {
Conversation::where([
'status_id' => $sid,
'to_id' => $dm->from_id,
'from_id' => $dm->to_id
])->delete();
Conversation::where([
'status_id' => $sid,
'from_id' => $dm->from_id,
'to_id' => $dm->to_id
])->delete();
}
}
StatusService::del($status->id, true);
$status->delete(); $status->delete();
$dm->delete(); $dm->delete();

View file

@ -16,7 +16,11 @@ use App\{
}; };
use Auth, DB, Cache; use Auth, DB, Cache;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Services\BookmarkService;
use App\Services\ConfigCacheService; use App\Services\ConfigCacheService;
use App\Services\HashtagService;
use App\Services\LikeService;
use App\Services\ReblogService;
use App\Services\StatusHashtagService; use App\Services\StatusHashtagService;
use App\Services\SnowflakeService; use App\Services\SnowflakeService;
use App\Services\StatusService; use App\Services\StatusService;
@ -76,10 +80,8 @@ class DiscoverController extends Controller
$tag = $request->input('hashtag'); $tag = $request->input('hashtag');
$hashtag = Hashtag::whereName($tag)->firstOrFail(); $hashtag = Hashtag::whereName($tag)->firstOrFail();
if($user && $page == 1) { if($user) {
$res['follows'] = HashtagFollow::whereUserId($user->id) $res['follows'] = HashtagService::isFollowing($user->profile_id, $hashtag->id);
->whereHashtagId($hashtag->id)
->exists();
} }
$res['hashtag'] = [ $res['hashtag'] = [
'name' => $hashtag->name, 'name' => $hashtag->name,
@ -88,6 +90,12 @@ class DiscoverController extends Controller
if($user) { if($user) {
$tags = StatusHashtagService::get($hashtag->id, $page, $end); $tags = StatusHashtagService::get($hashtag->id, $page, $end);
$res['tags'] = collect($tags) $res['tags'] = collect($tags)
->map(function($tag) use($user) {
$tag['status']['favourited'] = (bool) LikeService::liked($user->profile_id, $tag['status']['id']);
$tag['status']['reblogged'] = (bool) ReblogService::get($user->profile_id, $tag['status']['id']);
$tag['status']['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $tag['status']['id']);
return $tag;
})
->filter(function($tag) { ->filter(function($tag) {
if(!StatusService::get($tag['status']['id'])) { if(!StatusService::get($tag['status']['id'])) {
return false; return false;

View file

@ -9,6 +9,7 @@ use App\{
HashtagFollow, HashtagFollow,
Status Status
}; };
use App\Services\HashtagService;
class HashtagFollowController extends Controller class HashtagFollowController extends Controller
{ {
@ -37,9 +38,11 @@ class HashtagFollowController extends Controller
if($hashtagFollow->wasRecentlyCreated) { if($hashtagFollow->wasRecentlyCreated) {
$state = 'created'; $state = 'created';
HashtagService::follow($profile->id, $hashtag->id);
// todo: send to HashtagFollowService // todo: send to HashtagFollowService
} else { } else {
$state = 'deleted'; $state = 'deleted';
HashtagService::unfollow($profile->id, $hashtag->id);
$hashtagFollow->delete(); $hashtagFollow->delete();
} }

View file

@ -33,6 +33,12 @@ class LikeController extends Controller
$like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail(); $like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail();
UnlikePipeline::dispatch($like); UnlikePipeline::dispatch($like);
} else { } else {
abort_if(
Like::whereProfileId($user->profile_id)
->where('created_at', '>', now()->subDay())
->count() >= Like::MAX_PER_DAY,
429
);
$count = $status->likes_count > 4 ? $status->likes_count : $status->likes()->count(); $count = $status->likes_count > 4 ? $status->likes_count : $status->likes()->count();
$like = Like::firstOrCreate([ $like = Like::firstOrCreate([
'profile_id' => $user->profile_id, 'profile_id' => $user->profile_id,

View file

@ -81,7 +81,6 @@ class StoryFanout implements ShouldQueue
foreach($audience as $url) { foreach($audience as $url) {
$version = config('pixelfed.version'); $version = config('pixelfed.version');
$appUrl = config('app.url'); $appUrl = config('app.url');
$proxy = config('');
$headers = HttpSignature::sign($profile, $url, $activity, [ $headers = HttpSignature::sign($profile, $url, $activity, [
'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})", 'User-Agent' => "(Pixelfed/{$version}; +{$appUrl})",

View file

@ -9,6 +9,8 @@ class Like extends Model
{ {
use SoftDeletes; use SoftDeletes;
const MAX_PER_DAY = 200;
/** /**
* The attributes that should be mutated to dates. * The attributes that should be mutated to dates.
* *

View file

@ -2,12 +2,16 @@
namespace App\Services; namespace App\Services;
use Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis;
use App\Hashtag; use App\Hashtag;
use App\StatusHashtag; use App\StatusHashtag;
use App\HashtagFollow;
class HashtagService { class HashtagService {
const FOLLOW_KEY = 'pf:services:hashtag:following:';
public static function get($id) public static function get($id)
{ {
return Cache::remember('services:hashtag:by_id:' . $id, 3600, function() use($id) { return Cache::remember('services:hashtag:by_id:' . $id, 3600, function() use($id) {
@ -29,4 +33,35 @@ class HashtagService {
}); });
} }
public static function isFollowing($pid, $hid)
{
$res = Redis::zscore(self::FOLLOW_KEY . $pid, $hid);
if($res) {
return true;
}
$synced = Cache::get(self::FOLLOW_KEY . $pid . ':synced');
if(!$synced) {
$tags = HashtagFollow::whereProfileId($pid)
->get()
->each(function($tag) use($pid) {
self::follow($pid, $tag->hashtag_id);
});
Cache::set(self::FOLLOW_KEY . $pid . ':synced', true, 1209600);
return (bool) Redis::zscore(self::FOLLOW_KEY . $pid, $hid) > 1;
}
return false;
}
public static function follow($pid, $hid)
{
return Redis::zadd(self::FOLLOW_KEY . $pid, $hid, $hid);
}
public static function unfollow($pid, $hid)
{
return Redis::zrem(self::FOLLOW_KEY . $pid, $hid);
}
} }

Binary file not shown.

BIN
public/js/compose-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/daci-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/dffc-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/dmyh-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/dmym-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/dsfc-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/dssc-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/home-nza92p6rg.js vendored Normal file

Binary file not shown.

BIN
public/js/installer.js vendored

Binary file not shown.

View file

@ -1 +0,0 @@
/*! @source http://purl.eligrey.com/github/canvas-toBlob.js/blob/master/canvas-toBlob.js */

BIN
public/js/manifest.js vendored

Binary file not shown.

Binary file not shown.

BIN
public/js/post-nza92p6rg.js vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
public/js/profile-nza92p6rg.js vendored Normal file

Binary file not shown.

BIN
public/js/spa.js vendored

Binary file not shown.

Binary file not shown.