From 6bf72b66650252687252af9122fc57a45fb9ceb4 Mon Sep 17 00:00:00 2001 From: Nicolas Hoizey Date: Mon, 16 Jan 2023 09:05:17 +0100 Subject: [PATCH 1/6] Suggested weight optimization for the SVG logo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I ran the logo in [SVGOMG](https://jakearchibald.github.io/svgomg/), a tool for optimizing SVG images, and it saves 54 % of the weight without losing anything visually. I kept the pretty markup, even if minification would have saved a few more bytes. --- public/img/pixelfed-icon-color.svg | Bin 11941 -> 5885 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/img/pixelfed-icon-color.svg b/public/img/pixelfed-icon-color.svg index dfaf03fbea8b3c6138896797cacecf9a46f68905..86fe206fde22924a070272d12fd49df7e9aae3b0 100644 GIT binary patch literal 5885 zcmc&&NpIUY7`^vb5Gn>}52CqcIosun)z_y6$|Ok!w%7achOzTWHeJ&L9`Dj>&K8rQmwF8CjbL2Lxe?nS z;Zgjj`0fqrkyt!S%THxGS!An&{&|}6b3#XetjvF3A^FeipI*pzM02u*P4r@ zw%*|&+ryYA_AQ>J;hHd!{gYGnUxa#eb=ev8jQyjLGSPK6{KxE<0guSL*8AjgGCv8p zwl4`v#Eq`a&rX>y#Aq}^&b`q6Ld4N%)D8bJ^JB>sSx4qe!9|liO7OTr5CuG-U{C<2 zrx3{KWAcgw5_&WWuYVSSv3XABOUaYQel55O2^S(j1IYH-DceV*OO$bE%(KZ8Map!; zU*LUP;xOYzp-5w<0v?7JQt?1D*9t~|@EnCq+Lt<^pJ-hdPXdO?iOCTtt}bYa$SxGQ zsZ54U<;XXmt8s{lzJeRD7{+mfUakxaK@n@8erj&~kYkUK3-hmY(!8m8M@g`EiEbS* z$>WI2#OESL0uW&N7?U*< z786&>*Qh)m>e}!{Yxq9(ScdeG=i252ktDXD+@?yEO7fshbcL-2Y-|7`llJVsF?4yV(9c`5`p;oK1wbJcL9AEOWqMFxcclD9_|5#{Ps z5PttD+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psfA-W2=F8 znsv@^bj>FHR(;xDzR#*H4CA(O>Fs$gk|;}hOATZVop4Y4Mg#@tj5*)QeYvwMKlkPS z`jJuRnMd?|!Ghp>cZ_J&>%R7;<~jaDE=iN>CH(iq%{<3};H(=R^e3qr(oP3jv<2N& z99U`_YDInLKz_-f*Mpm9MxBRVz=NjWgXJRP+dN3w{){lwPkZBY+?2Q7M8A~^Ga+Pq zx>oIuE^on^4p}JgG}F{oCBsO*GWOXj$aOiv-%! zHuD@0@;e9JNaME^xO$_0-{nFiEEn;XE(X${YJeMnyGR>Ft}7pMCFQ{SnNjDV=ev-K zy3d29SN{DTq;Te!RmjCp_25?(gnrs?zUsoSf4Od2(%uVg_FHubSFJAEm;Y-P^GD3x z5fvY1ljD!=;Wx-`twCdXB|6Ap{DaPQzYj_?{ZSuuUdk`;%1^IDA75;zg?hhuFt{~v O_mA>{-yi;T_U8YD+xT4o From e3ed684f985d804b3a59d42c445c112ca8c6323b Mon Sep 17 00:00:00 2001 From: Brayd <116094473+br4yd@users.noreply.github.com> Date: Thu, 19 Jan 2023 21:43:57 +0100 Subject: [PATCH 2/6] Minor text change Just a minor text change. The user should be adressed by simply using "you". Otherwise a user could think it's an error that just happened randomly so they retry. By addressing them with "you" it can make this message a bit more clear. --- app/Http/Controllers/BookmarkController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/BookmarkController.php b/app/Http/Controllers/BookmarkController.php index 59ffeab36..f5f59457b 100644 --- a/app/Http/Controllers/BookmarkController.php +++ b/app/Http/Controllers/BookmarkController.php @@ -31,7 +31,7 @@ class BookmarkController extends Controller abort_if( $profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id), 404, - 'Error: Cannot bookmark private posts from accounts you do not follow.' + 'Error: You cannot bookmark private posts from accounts you do not follow.' ); } From df1327f41539050ce49eea3524cfe8e4f419c57c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 00:28:53 -0700 Subject: [PATCH 3/6] Optimize logos --- public/img/pixelfed-icon-black.svg | Bin 1094 -> 318 bytes public/img/pixelfed-icon-color.svg | Bin 5885 -> 5334 bytes public/img/pixelfed-icon-grey.svg | Bin 1092 -> 333 bytes public/img/pixelfed-icon-white.svg | Bin 0 -> 330 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/img/pixelfed-icon-white.svg diff --git a/public/img/pixelfed-icon-black.svg b/public/img/pixelfed-icon-black.svg index 32c7e52fe9e0b835e856fd84d77ce4da9beb249c..449c9d34bdccc4fd0ffccd5cd4426da737a3f546 100644 GIT binary patch literal 318 zcmX|+%WlLV3`KthvB!XUkCJSgGUxioKbLY{d!B2(pQLQ9K{IfB%o3GSk{0>U-9Kw)W6$5wF{j?N2AvEMQ_Mt& zDiEOiIQ-5`tyB&{giic7;?+MdLPLt=6F7_6f{Xra!61bNh-icXs}Bs|HH8Wbs60J5 zg<^M}>OT77EIg@n76>*`3{5+27@hIqV9HN+(*bnxbk@@bdh_J$YbixMzRT3}X`8OM LapZF7_WuvR%b82~ literal 1094 zcmZuw(QcbC6n*bkc;3qSFw z?(yN;B=?tNgHEO&YTKrm5sHy%b6eDHnc_dcfBFjFZ|{=fRHAcTj8%#y?JgKqrY@`T z7M*Hy{$VdEridcxUc44%7{NB}km70_yG;=iS*7VtE`wem!#QobQe?!ZcTkg)XFCsEDF5 zV=9J#OSGfjLP5*YqX-m0U@3q|eqcl76ku9NXj!@qXBW@tk%xpb88WH8kP;!4i_o6O zB%(}2g010Q$cW}F*6IU0ltggBIOiVJQK5v61zMw=D8VBk!1lsribP=)YZ{@IE|Y}w z*ga@vVukKGC0cQ=netZf4&;Q=Ag9+bi-?H8vj%buEf*o>AzGuFM4ZMl;%L8u!-&KH v#|q%jd-RN_%eS+~m%4?!{ZwV0!Eis_QP20&oxB@KP%glGFf9`IgKYl+GEx&L diff --git a/public/img/pixelfed-icon-color.svg b/public/img/pixelfed-icon-color.svg index 86fe206fde22924a070272d12fd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TrV=IPcSO))#b;OAL$$qZkM7(d?57$+ zE|Nnv)OKC%ToV?Zee=e`wmRGT#pcAr#KUPg@g^I&?RV=iU}WbJD%mz_v%*xIDjfWbDc$ zJ9^!@_Kk2ji>dnSPwk%tc~NlJx!0C(@n3div|HE|czqBmfYaS@PPq|U^T>xRh&0tK z;an#W2!%E*m?>zU1`L4$2+Rc#sSj+3yaIe?5}K!e!O6uFdJqw1Tt!@&AYxQ1?IUzA z5*jluW678BCgRixo*4as9Vse>X_8hBoZxALA4aIlwf=2a!unXP7I6DLYFHl zMB*Q`FtI@I1*1j_VYm(!@CM|hHXvt~FpsH>!LtE!0xg#j6A@aXhQ@*=Di-K|0Y@=S w08TW(pZDkqkC$)b4$oBsSNpNtwid(v^hZ72Pk-`$q+u}w@4+}p{r|E42Zn1B?*IS* diff --git a/public/img/pixelfed-icon-white.svg b/public/img/pixelfed-icon-white.svg new file mode 100644 index 0000000000000000000000000000000000000000..f61b94713529f9d56b24aa6e265515a78966b2a4 GIT binary patch literal 330 zcmX|-%Z`IE3`Kt>%B*7?=S3=DGZMS5`URuH5G49g$-t;zKc+>qv5rsdYbn*d3}PL- zoNDP%iqwxo%5VO?OxL-VDd+p4DAsj_)xhmB6oiNcFUqF6f8`{)S{}&>ho4%5j)qB~ zFeQ{27|5M=zp=oX%PyG6ssBd3`sYPyh$Z_7&Qh}AN`JOsh{FPuWRwA`cMRY)hbjw% zo*x{N+MMUQjlMW3&nli3fsGu)(@q<~XMEV1^P^pK06lp=>v@B`c}np;PE##E+O~bO Vdi+d%E&HXv-nvc}O||_+^9NgJPc;Al literal 0 HcmV?d00001 From 83e1e203cedd7484a7841e3c93e6452dd3ee9840 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 02:27:23 -0700 Subject: [PATCH 4/6] Update SharePipeline, fix share handling and notification generation --- app/Http/Controllers/Api/ApiV1Controller.php | 6 +-- app/Jobs/SharePipeline/SharePipeline.php | 45 ++++++----------- app/Jobs/SharePipeline/UndoSharePipeline.php | 53 +++++++++++--------- app/Notification.php | 2 +- app/Util/ActivityPub/Inbox.php | 27 +++++----- app/Util/ActivityPub/Validator/Announce.php | 7 +-- 6 files changed, 63 insertions(+), 77 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 0c44fd47f..cd999318d 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2814,9 +2814,7 @@ class ApiV1Controller extends Controller 'visibility' => 'public' ]); - if($share->wasRecentlyCreated == true) { - SharePipeline::dispatch($share); - } + SharePipeline::dispatch($share)->onQueue('low'); StatusService::del($status->id); ReblogService::add($user->profile_id, $status->id); @@ -2858,7 +2856,7 @@ class ApiV1Controller extends Controller return $this->json($res); } - UndoSharePipeline::dispatch($reblog); + UndoSharePipeline::dispatch($reblog)->onQueue('low'); ReblogService::del($user->profile_id, $status->id); $res = StatusService::getMastodon($status->id); diff --git a/app/Jobs/SharePipeline/SharePipeline.php b/app/Jobs/SharePipeline/SharePipeline.php index cd54b90eb..2cc807acb 100644 --- a/app/Jobs/SharePipeline/SharePipeline.php +++ b/app/Jobs/SharePipeline/SharePipeline.php @@ -58,47 +58,32 @@ class SharePipeline implements ShouldQueue return; } - $exists = Notification::whereProfileId($target->id) - ->whereActorId($status->profile_id) - ->whereAction('share') - ->whereItemId($status->reblog_of_id) - ->whereItemType('App\Status') - ->exists(); - if($target->id === $status->profile_id) { $this->remoteAnnounceDeliver(); return true; } - if($exists === true) { - return true; - } - - $this->remoteAnnounceDeliver(); - ReblogService::addPostReblog($parent->id, $status->id); - $parent->reblogs_count = $parent->shares()->count(); + $parent->reblogs_count = $parent->reblogs_count + 1; $parent->save(); StatusService::del($parent->id); - try { - $notification = new Notification; - $notification->profile_id = $target->id; - $notification->actor_id = $actor->id; - $notification->action = 'share'; - $notification->message = $status->shareToText(); - $notification->rendered = $status->shareToHtml(); - $notification->item_id = $status->reblog_of_id ?? $status->id; - $notification->item_type = "App\Status"; - $notification->save(); + Notification::firstOrCreate( + [ + 'profile_id' => $target->id, + 'actor_id' => $actor->id, + 'action' => 'share', + 'item_type' => 'App\Status', + 'item_id' => $status->reblog_of_id ?? $status->id, + ], + [ + 'message' => $status->shareToText(), + 'rendered' => $status->shareToHtml() + ] + ); - $redis = Redis::connection(); - $key = config('cache.prefix').':user.'.$status->profile_id.'.notifications'; - $redis->lpush($key, $notification->id); - } catch (Exception $e) { - Log::error($e); - } + return $this->remoteAnnounceDeliver(); } public function remoteAnnounceDeliver() diff --git a/app/Jobs/SharePipeline/UndoSharePipeline.php b/app/Jobs/SharePipeline/UndoSharePipeline.php index 596d4d2da..d63f909b3 100644 --- a/app/Jobs/SharePipeline/UndoSharePipeline.php +++ b/app/Jobs/SharePipeline/UndoSharePipeline.php @@ -33,35 +33,39 @@ class UndoSharePipeline implements ShouldQueue { $status = $this->status; $actor = $status->profile; - $parent = $status->parent(); - $target = $status->parent()->profile; + $parent = Status::find($status->reblog_of_id); - ReblogService::removePostReblog($parent->id, $status->id); + if($parent) { + $target = $parent->profile_id; + ReblogService::removePostReblog($parent->id, $status->id); - if ($status->uri !== null) { + if($parent->reblogs_count > 0) { + $parent->reblogs_count = $parent->reblogs_count - 1; + $parent->save(); + StatusService::del($parent->id); + } + + $notification = Notification::whereProfileId($target) + ->whereActorId($status->profile_id) + ->whereAction('share') + ->whereItemId($status->reblog_of_id) + ->whereItemType('App\Status') + ->first(); + + if($notification) { + $notification->forceDelete(); + } + } + + if ($status->uri != null) { return; } - if($target->domain === null) { - Notification::whereProfileId($target->id) - ->whereActorId($status->profile_id) - ->whereAction('share') - ->whereItemId($status->reblog_of_id) - ->whereItemType('App\Status') - ->delete(); + if(config_cache('federation.activitypub.enabled') == false) { + return $status->delete(); + } else { + return $this->remoteAnnounceDeliver(); } - - $this->remoteAnnounceDeliver(); - - if($parent->reblogs_count > 0) { - $parent->reblogs_count = $parent->reblogs_count - 1; - $parent->save(); - StatusService::del($parent->id); - } - - $status->forceDelete(); - - return 1; } public function remoteAnnounceDeliver() @@ -124,5 +128,8 @@ class UndoSharePipeline implements ShouldQueue $promise->wait(); + $status->delete(); + + return 1; } } diff --git a/app/Notification.php b/app/Notification.php index ebd6f6415..b0877978f 100644 --- a/app/Notification.php +++ b/app/Notification.php @@ -16,7 +16,7 @@ class Notification extends Model */ protected $dates = ['deleted_at']; - protected $fillable = ['*']; + protected $guarded = []; public function actor() { diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index c8fa9500b..6b6586433 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -569,13 +569,9 @@ class Inbox return; } - if(Helpers::validateLocalUrl($activity) == false) { - return; - } - $parent = Helpers::statusFetch($activity); - if(empty($parent)) { + if(!$parent || empty($parent)) { return; } @@ -590,15 +586,18 @@ class Inbox 'type' => 'share' ]); - Notification::firstOrCreate([ - 'profile_id' => $parent->profile->id, - 'actor_id' => $actor->id, - 'action' => 'share', - 'message' => $status->replyToText(), - 'rendered' => $status->replyToHtml(), - 'item_id' => $parent->id, - 'item_type' => 'App\Status' - ]); + Notification::firstOrCreate( + [ + 'profile_id' => $parent->profile_id, + 'actor_id' => $actor->id, + 'action' => 'share', + 'item_id' => $parent->id, + 'item_type' => 'App\Status', + ], [ + 'message' => $status->replyToText(), + 'rendered' => $status->replyToHtml(), + ] + ); $parent->reblogs_count = $parent->reblogs_count + 1; $parent->save(); diff --git a/app/Util/ActivityPub/Validator/Announce.php b/app/Util/ActivityPub/Validator/Announce.php index b6f89eec9..d862fe9d7 100644 --- a/app/Util/ActivityPub/Validator/Announce.php +++ b/app/Util/ActivityPub/Validator/Announce.php @@ -11,18 +11,15 @@ class Announce { { $valid = Validator::make($payload, [ '@context' => 'required', - 'id' => 'required|string', + 'id' => 'required|url', 'type' => [ 'required', Rule::in(['Announce']) ], 'actor' => 'required|url', - 'published' => 'required|date', - 'to' => 'required', - 'cc' => 'required', 'object' => 'required|url' ])->passes(); return $valid; } -} \ No newline at end of file +} From d67fcffb02712090660183af992dc088b28923ec Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 02:29:53 -0700 Subject: [PATCH 5/6] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b2da5118..95b4820af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,8 @@ - Update AdminApiController, fix postgres support ([84fb59d0](https://github.com/pixelfed/pixelfed/commit/84fb59d0)) - Update StatusReplyPipeline, fix comment counts ([164aa577](https://github.com/pixelfed/pixelfed/commit/164aa577)) - Update ComposeModal, add Alt Text button to caption screen ([4db48188](https://github.com/pixelfed/pixelfed/commit/4db48188)) +- Update AccountService, fix actor cache invalidation ([498b46f7](https://github.com/pixelfed/pixelfed/commit/498b46f7)) +- Update SharePipeline, fix share handling and notification generation ([83e1e203](https://github.com/pixelfed/pixelfed/commit/83e1e203)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4) From 222dc3a1925fb0d5c12c1cfe64951d5c05d091c0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Jan 2023 02:33:50 -0700 Subject: [PATCH 6/6] Update test --- tests/Unit/ActivityPub/Verb/AnnounceTest.php | 48 -------------------- 1 file changed, 48 deletions(-) diff --git a/tests/Unit/ActivityPub/Verb/AnnounceTest.php b/tests/Unit/ActivityPub/Verb/AnnounceTest.php index c38fffb34..91a4fdfe8 100644 --- a/tests/Unit/ActivityPub/Verb/AnnounceTest.php +++ b/tests/Unit/ActivityPub/Verb/AnnounceTest.php @@ -53,22 +53,6 @@ class AnnounceTest extends TestCase 'object' => 'https://example.org/p/bob/100000000000000', ]; - $this->invalidDate = [ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', - 'type' => 'Announce', - 'actor' => 'https://example.org/users/alice', - 'published' => '2018-12-31T23:59:59ZEZE', - 'to' => [ - 'https://www.w3.org/ns/activitystreams#Public' - ], - 'cc' => [ - 'https://example.org/users/bob', - 'https://example.org/users/alice/followers' - ], - 'object' => 'https://example.org/p/bob/100000000000000', - ]; - $this->contextMissing = [ 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', 'type' => 'Announce', @@ -84,25 +68,6 @@ class AnnounceTest extends TestCase 'object' => 'https://example.org/p/bob/100000000000000', ]; - $this->audienceMissing = [ - 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', - 'type' => 'Announce', - 'actor' => 'https://example.org/users/alice', - 'published' => '2018-12-31T23:59:59Z', - 'object' => 'https://example.org/p/bob/100000000000000', - ]; - - $this->audienceMissing2 = [ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', - 'type' => 'Announce', - 'actor' => 'https://example.org/users/alice', - 'published' => '2018-12-31T23:59:59Z', - 'to' => null, - 'cc' => null, - 'object' => 'https://example.org/p/bob/100000000000000', - ]; - $this->invalidActor = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => 'https://example.org/users/alice/statuses/100000000000001/activity', @@ -185,25 +150,12 @@ class AnnounceTest extends TestCase $this->assertFalse(Announce::validate($this->invalidAnnounce)); } - /** @test */ - public function invalid_date() - { - $this->assertFalse(Announce::validate($this->invalidDate)); - } - /** @test */ public function context_missing() { $this->assertFalse(Announce::validate($this->contextMissing)); } - /** @test */ - public function audience_missing() - { - $this->assertFalse(Announce::validate($this->audienceMissing)); - $this->assertFalse(Announce::validate($this->audienceMissing2)); - } - /** @test */ public function invalid_actor() {