From 6bf594f8761b0f0c0add91dcc939bab03b8e1300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Fri, 24 Jul 2020 14:30:42 +0200 Subject: [PATCH 1/4] Update Polish translation --- resources/lang/pl/helpcenter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/lang/pl/helpcenter.php b/resources/lang/pl/helpcenter.php index 43db4b3af..0624b65fd 100644 --- a/resources/lang/pl/helpcenter.php +++ b/resources/lang/pl/helpcenter.php @@ -21,6 +21,8 @@ return [ 'blockingAccounts' => 'Blokowanie kont', 'safetyTips' => 'Wskazówki dot. bezpieczeństwa', 'reportSomething' => 'Zgłaszanie treści', - 'dataPolicy' => 'Polityka przechowywania danych' + 'dataPolicy' => 'Polityka przechowywania danych', + + 'taggingPeople' => 'Tagowanie ludzi' ]; From c9452639945aa7c3eb1580283690214a0093f631 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 24 Jul 2020 19:49:49 -0600 Subject: [PATCH 2/4] Update Tag People, allow untagging yourself --- .../Controllers/InternalApiController.php | 16 ++++---- app/Http/Controllers/MediaTagController.php | 41 +++++++++++++++++++ app/Services/MediaTagService.php | 25 ++++++++++- .../assets/js/components/PostComponent.vue | 29 ++++++++++--- routes/web.php | 2 +- 5 files changed, 97 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 764893259..31ecd2563 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -332,6 +332,14 @@ class InternalApiController extends Controller $media->save(); } + $visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility; + $cw = $profile->cw == true ? true : $cw; + $status->is_nsfw = $cw; + $status->visibility = $visibility; + $status->scope = $visibility; + $status->type = $mediaType; + $status->save(); + foreach($tagged as $tg) { $mt = new MediaTag; $mt->status_id = $status->id; @@ -347,14 +355,6 @@ class InternalApiController extends Controller MediaTagService::sendNotification($mt); } - $visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility; - $cw = $profile->cw == true ? true : $cw; - $status->is_nsfw = $cw; - $status->visibility = $visibility; - $status->scope = $visibility; - $status->type = $mediaType; - $status->save(); - NewStatusPipeline::dispatch($status); Cache::forget('user:account:id:'.$profile->user_id); Cache::forget('profile:status_count:'.$profile->id); diff --git a/app/Http/Controllers/MediaTagController.php b/app/Http/Controllers/MediaTagController.php index 54d2c2620..3b583f95d 100644 --- a/app/Http/Controllers/MediaTagController.php +++ b/app/Http/Controllers/MediaTagController.php @@ -3,7 +3,9 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Services\MediaTagService; use App\MediaTag; +use App\Notification; use App\Profile; use App\UserFilter; use App\User; @@ -11,6 +13,11 @@ use Illuminate\Support\Str; class MediaTagController extends Controller { + public function __construct() + { + $this->middleware('auth'); + } + public function usernameLookup(Request $request) { abort_if(!$request->user(), 403); @@ -52,4 +59,38 @@ class MediaTagController extends Controller return $results; } + + public function untagProfile(Request $request) + { + abort_if(!$request->user(), 403); + + $this->validate($request, [ + 'status_id' => 'required', + 'profile_id' => 'required' + ]); + + $user = $request->user(); + $status_id = $request->input('status_id'); + $profile_id = (int) $request->input('profile_id'); + + abort_if((int) $user->profile_id !== $profile_id, 400); + + $tag = MediaTag::whereStatusId($status_id) + ->whereProfileId($profile_id) + ->first(); + + if(!$tag) { + return []; + } + Notification::whereItemType('App\MediaTag') + ->whereItemId($tag->id) + ->whereProfileId($profile_id) + ->whereAction('tagged') + ->delete(); + + MediaTagService::untag($status_id, $profile_id); + + return [200]; + + } } diff --git a/app/Services/MediaTagService.php b/app/Services/MediaTagService.php index 087487d44..fea1f2b5e 100644 --- a/app/Services/MediaTagService.php +++ b/app/Services/MediaTagService.php @@ -15,12 +15,24 @@ class MediaTagService const CACHE_KEY = 'pf:services:media_tags:id:'; public static function get($mediaId, $usernames = true) + { + return self::coldGet($mediaId, $usernames); + } + + public static function coldGet($mediaId, $usernames = true) { $k = 'pf:services:media_tags:get:sid:' . $mediaId; return Cache::remember($k, now()->addMinutes(60), function() use($mediaId, $usernames) { $key = self::CACHE_KEY . $mediaId; if(Redis::zCount($key, '-inf', '+inf') == 0) { - return []; + $tags = MediaTag::whereStatusId($mediaId)->get(); + if($tags->count() == 0) { + return []; + } + + foreach ($tags as $t) { + self::set($mediaId, $t->profile_id); + } } $res = Redis::zRange($key, 0, -1); if(!$usernames) { @@ -52,6 +64,7 @@ class MediaTagService } return [ + 'id' => (string) $id, 'username' => $profile->username, 'avatar' => $profile->avatarUrl() ]; @@ -75,4 +88,14 @@ class MediaTagService return; } + public static function untag($statusId, $profileId) + { + MediaTag::whereStatusId($statusId) + ->whereProfileId($profileId) + ->delete(); + $key = 'pf:services:media_tags:get:sid:' . $statusId; + Redis::zRem(self::CACHE_KEY.$statusId, $profileId); + Cache::forget($key); + return true; + } } \ No newline at end of file diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 14fcd03d3..d6e3934af 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -595,16 +595,17 @@ title="Tagged People" body-class="list-group-flush py-3 px-0">
-
+
@@ -1392,6 +1393,22 @@ export default { showTaggedPeopleModal() { this.$refs.taggedModal.show(); + }, + + untagMe() { + this.$refs.taggedModal.hide(); + let id = this.user.id; + axios.post('/api/local/compose/tag/untagme', { + status_id: this.statusId, + profile_id: id + }).then(res => { + this.status.taggedPeople = this.status.taggedPeople.filter(t => { + return t.id != id; + }); + swal('Untagged', 'You have been untagged from this post.', 'success'); + }).catch(err => { + swal('An Error Occurred', 'Please try again later.', 'error'); + }); } }, diff --git a/routes/web.php b/routes/web.php index bfec403d8..9323b25d3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -187,7 +187,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::post('compose/media/update/{id}', 'MediaController@composeUpdate')->middleware('throttle:maxComposeMediaUpdatesPerHour,60')->middleware('throttle:maxComposeMediaUpdatesPerDay,1440')->middleware('throttle:maxComposeMediaUpdatesPerMonth,43800'); Route::get('compose/location/search', 'ApiController@composeLocationSearch'); Route::get('compose/tag/search', 'MediaTagController@usernameLookup'); - + Route::post('compose/tag/untagme', 'MediaTagController@untagProfile'); }); Route::group(['prefix' => 'admin'], function () { Route::post('moderate', 'Api\AdminApiController@moderate'); From 45fb84c28f06563f51f33abd31c32e67784a2bc8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 24 Jul 2020 19:50:30 -0600 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25ae19bc7..ae4974185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ - Updated NotificationTransformer, add modlog and tagged types. ([49dab6fb](https://github.com/pixelfed/pixelfed/commit/49dab6fb)) - Updated comments, fix remote reply bug. ([f330616](https://github.com/pixelfed/pixelfed/commit/f330616)) - Updated PostComponent, add tagged people to mobile layout. ([7a2c2e78](https://github.com/pixelfed/pixelfed/commit/7a2c2e78)) +- Updated Tag People, allow untagging yourself. ([c9452639](https://github.com/pixelfed/pixelfed/commit/c9452639)) ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9) ### Added From 8f723941d783566470cb204ce862c8b84853edbb Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 24 Jul 2020 19:52:31 -0600 Subject: [PATCH 4/4] Update compiled assets --- public/js/status.js | Bin 78777 -> 79393 bytes public/mix-manifest.json | Bin 1939 -> 1939 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/status.js b/public/js/status.js index 4dc5e467a0e3e721d11c9bfd860bda1026d854af..405ef5984b609a01e86c31add0f690543543d4e8 100644 GIT binary patch delta 965 zcmY+DT}TvB6vw$at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4fa7ee0 100644 GIT binary patch delta 32 ocmbQtKbe2SLN*aYlO%JCL<@7%#KdF^GXsMZBZI`rTiNab0H72KF#rGn delta 32 ocmbQtKbe2SLN*bLWE0C|Qv)+&!_>4SQxo%)L^FfQTiNab0HECpJ^%m!