From 9e221fc6b3ff56d1e8615f9dcf73d3db9298c4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Wed, 24 Jun 2020 01:00:17 +0200 Subject: [PATCH 01/31] Fix typo in Polish translation --- resources/lang/pl/site.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/pl/site.php b/resources/lang/pl/site.php index 4b0b3ea82..826ad5b9a 100644 --- a/resources/lang/pl/site.php +++ b/resources/lang/pl/site.php @@ -13,7 +13,7 @@ return [ 'currentLocale' => 'Obecny język', 'selectLocale' => 'Wybierz jeden z dostępnych języków', 'contact' => 'Kontakt', - 'contact-us' => 'Skontaktuj się z naim', + 'contact-us' => 'Skontaktuj się z nami', 'places' => 'Miejsca', 'profiles' => 'Profile', From 2c440b4882d7ec093d9fc18087de0dc98e10958f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 Jul 2020 21:12:39 -0600 Subject: [PATCH 02/31] Update AccountController, prevent blocking admins --- app/Http/Controllers/AccountController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index a18380763..09f4ba1c9 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -244,7 +244,7 @@ class AccountController extends Controller switch ($type) { case 'user': $profile = Profile::findOrFail($item); - if ($profile->id == $user->id) { + if ($profile->id == $user->id || $profile->user->is_admin == true) { return abort(403); } $class = get_class($profile); From c54b29c559a67b96a02221dfa01d0d8bc2d02828 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 Jul 2020 21:25:11 -0600 Subject: [PATCH 03/31] Added MediaPathService --- app/Services/MediaPathService.php | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 app/Services/MediaPathService.php diff --git a/app/Services/MediaPathService.php b/app/Services/MediaPathService.php new file mode 100644 index 000000000..c8ae1422f --- /dev/null +++ b/app/Services/MediaPathService.php @@ -0,0 +1,51 @@ +id . (string) $account->created_at); + $path = "public/m/{$monthHash}/{$userHash}"; + break; + + case 2: + $monthHash = substr($mh, 0, 9).'-'.substr($mh, 9, 6); + $userHash = $account->profile_id; + $random = Str::random(12); + $path = "public/m/_v2/{$userHash}/{$monthHash}/{$random}"; + break; + + default: + $monthHash = substr($mh, 0, 9).'-'.substr($mh, 9, 6); + $userHash = $account->profile_id; + $random = Str::random(12); + $path = "public/m/_v2/{$userHash}/{$monthHash}/{$random}"; + break; + } + } + if($account instanceOf Profile) { + $monthHash = substr($mh, 0, 9).'-'.substr($mh, 9, 6); + $userHash = $account->id; + $random = Str::random(12); + $path = "public/m/_v2/{$userHash}/{$monthHash}/{$random}"; + } + return $path; + } + +} \ No newline at end of file From 588642123eff60b6e8da251b45e9e91b82ae09b5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 Jul 2020 21:27:34 -0600 Subject: [PATCH 04/31] Update Api controllers, use MediaPathService --- app/Http/Controllers/Api/ApiV1Controller.php | 12 +++++++----- app/Http/Controllers/Api/BaseApiController.php | 6 ++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index edf89261c..dd6112831 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -47,6 +47,7 @@ use App\Jobs\VideoPipeline\{ }; use App\Services\{ NotificationService, + MediaPathService, SearchApiV2Service }; @@ -646,6 +647,10 @@ class ApiV1Controller extends Controller $profile = Profile::findOrFail($id); + if($profile->user->is_admin == true) { + abort(400, 'You cannot block an admin'); + } + Follower::whereProfileId($profile->id)->whereFollowingId($pid)->delete(); Follower::whereProfileId($pid)->whereFollowingId($profile->id)->delete(); Notification::whereProfileId($pid)->whereActorId($profile->id)->delete(); @@ -1030,9 +1035,6 @@ class ApiV1Controller extends Controller $filterClass = in_array($request->input('filter_class'), Filter::classes()) ? $request->input('filter_class') : null; $filterName = in_array($request->input('filter_name'), Filter::names()) ? $request->input('filter_name') : null; - $monthHash = hash('sha1', date('Y').date('m')); - $userHash = hash('sha1', $user->id . (string) $user->created_at); - $photo = $request->file('file'); $mimes = explode(',', config('pixelfed.media_types')); @@ -1040,7 +1042,7 @@ class ApiV1Controller extends Controller abort(403, 'Invalid or unsupported mime type.'); } - $storagePath = "public/m/{$monthHash}/{$userHash}"; + $storagePath = MediaPathService::get($user, 2); $path = $photo->store($storagePath); $hash = \hash_file('sha256', $photo); @@ -1916,7 +1918,7 @@ class ApiV1Controller extends Controller foreach($bookmarks as $id) { $res[] = \App\Services\StatusService::get($id); } - return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); + return $res; } /** diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 6b18f8358..433841fbf 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -35,6 +35,7 @@ use App\Jobs\VideoPipeline\{ VideoThumbnail }; use App\Services\NotificationService; +use App\Services\MediaPathService; class BaseApiController extends Controller { @@ -235,9 +236,6 @@ class BaseApiController extends Controller $filterClass = in_array($request->input('filter_class'), Filter::classes()) ? $request->input('filter_class') : null; $filterName = in_array($request->input('filter_name'), Filter::names()) ? $request->input('filter_name') : null; - $monthHash = hash('sha1', date('Y').date('m')); - $userHash = hash('sha1', $user->id . (string) $user->created_at); - $photo = $request->file('file'); $mimes = explode(',', config('pixelfed.media_types')); @@ -245,7 +243,7 @@ class BaseApiController extends Controller return; } - $storagePath = "public/m/{$monthHash}/{$userHash}"; + $storagePath = MediaPathService::get($user, 2); $path = $photo->store($storagePath); $hash = \hash_file('sha256', $photo); From 611c7b922ad103413de3d76af580becd6f9f3dc7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 12 Jul 2020 21:28:25 -0600 Subject: [PATCH 05/31] Update change log --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18cf88728..774089120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Add Instagram Import ([e2a6bdd0](https://github.com/pixelfed/pixelfed/commit/e2a6bdd0)) - Add notification preview to NotificationCard ([28445e27](https://github.com/pixelfed/pixelfed/commit/28445e27)) - Add Grid Mode to Timelines ([c1853ca8](https://github.com/pixelfed/pixelfed/commit/c1853ca8)) +- Add MediaPathService ([c54b29c5](https://github.com/pixelfed/pixelfed/commit/c54b29c5)) ### Updated - Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc)) @@ -59,6 +60,8 @@ - Updated Timeline.vue, hide like counts on grid mode. Fixes ([#2293](https://github.com/pixelfed/pixelfed/issues/2293)) ([cc18159f](https://github.com/pixelfed/pixelfed/commit/cc18159f)) - Updated Timeline.vue, make grid mode photos clickable. Fixes ([#2292](https://github.com/pixelfed/pixelfed/issues/2292)) ([6db68184](https://github.com/pixelfed/pixelfed/commit/6db68184)) - Updated ComposeModal.vue, use vue tooltips. Fixes ([#2142](https://github.com/pixelfed/pixelfed/issues/2142)) ([2b753123](https://github.com/pixelfed/pixelfed/commit/2b753123)) +- Updated AccountController, prevent blocking admins. ([2c440b48](https://github.com/pixelfed/pixelfed/commit/2c440b48)) +- Updated Api controllers to use MediaPathService. ([58864212](https://github.com/pixelfed/pixelfed/commit/58864212)) ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9) ### Added From 711fc020e76d6ed5cfb4b89edc982b6ac97611ba Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:04:51 -0600 Subject: [PATCH 06/31] Add Media Tags --- app/Http/Controllers/MediaTagController.php | 55 +++++++++++++++++++ app/MediaTag.php | 13 +++++ ...0_06_30_180159_create_media_tags_table.php | 38 +++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 app/Http/Controllers/MediaTagController.php create mode 100644 app/MediaTag.php create mode 100644 database/migrations/2020_06_30_180159_create_media_tags_table.php diff --git a/app/Http/Controllers/MediaTagController.php b/app/Http/Controllers/MediaTagController.php new file mode 100644 index 000000000..54d2c2620 --- /dev/null +++ b/app/Http/Controllers/MediaTagController.php @@ -0,0 +1,55 @@ +user(), 403); + + $this->validate($request, [ + 'q' => 'required|string|min:1|max:50' + ]); + + $q = $request->input('q'); + + if(Str::of($q)->startsWith('@')) { + if(strlen($q) < 3) { + return []; + } + $q = mb_substr($q, 1); + } + + $blocked = UserFilter::whereFilterableType('App\Profile') + ->whereFilterType('block') + ->whereFilterableId($request->user()->profile_id) + ->pluck('user_id'); + + $blocked->push($request->user()->profile_id); + + $results = Profile::select('id','domain','username') + ->whereNotIn('id', $blocked) + ->whereNull('domain') + ->where('username','like','%'.$q.'%') + ->limit(15) + ->get() + ->map(function($r) { + return [ + 'id' => (string) $r->id, + 'name' => $r->username, + 'privacy' => true, + 'avatar' => $r->avatarUrl() + ]; + }); + + return $results; + } +} diff --git a/app/MediaTag.php b/app/MediaTag.php new file mode 100644 index 000000000..ff5fe9b6e --- /dev/null +++ b/app/MediaTag.php @@ -0,0 +1,13 @@ +belongsTo(Status::class); + } +} diff --git a/database/migrations/2020_06_30_180159_create_media_tags_table.php b/database/migrations/2020_06_30_180159_create_media_tags_table.php new file mode 100644 index 000000000..10b2b721b --- /dev/null +++ b/database/migrations/2020_06_30_180159_create_media_tags_table.php @@ -0,0 +1,38 @@ +id(); + $table->bigInteger('status_id')->unsigned()->index()->nullable(); + $table->bigInteger('media_id')->unsigned()->index(); + $table->bigInteger('profile_id')->unsigned()->index(); + $table->string('tagged_username')->nullable(); + $table->boolean('is_public')->default(true)->index(); + $table->json('metadata')->nullable(); + $table->unique(['media_id', 'profile_id']); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('media_tags'); + } +} From 9419cad0d2254956e4cd0eb9b0ffc4178acfa579 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:05:28 -0600 Subject: [PATCH 07/31] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 774089120..3711fcb43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Add notification preview to NotificationCard ([28445e27](https://github.com/pixelfed/pixelfed/commit/28445e27)) - Add Grid Mode to Timelines ([c1853ca8](https://github.com/pixelfed/pixelfed/commit/c1853ca8)) - Add MediaPathService ([c54b29c5](https://github.com/pixelfed/pixelfed/commit/c54b29c5)) +- Add Media Tags ([711fc020](https://github.com/pixelfed/pixelfed/commit/711fc020)) ### Updated - Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc)) From 51862b8b2b172236d8f1df5268312a53e3744ea7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:07:04 -0600 Subject: [PATCH 08/31] Update notification components, add modlog and tagged notification types --- resources/assets/js/components/Activity.vue | 13 +++++++++++++ resources/assets/js/components/NotificationCard.vue | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/resources/assets/js/components/Activity.vue b/resources/assets/js/components/Activity.vue index f0e217e24..d2e7e0012 100644 --- a/resources/assets/js/components/Activity.vue +++ b/resources/assets/js/components/Activity.vue @@ -42,6 +42,16 @@ {{truncate(n.account.username)}} shared your post.

+ +
+

+ {{truncate(n.account.username)}} tagged you in a post. +

+
{{timeAgo(n.created_at)}}
@@ -236,6 +246,9 @@ export default { case 'comment': return n.status.url; break; + case 'tagged': + return n.tagged.post_url; + break; } return '/'; }, diff --git a/resources/assets/js/components/NotificationCard.vue b/resources/assets/js/components/NotificationCard.vue index 645dc768f..2eb3034c6 100644 --- a/resources/assets/js/components/NotificationCard.vue +++ b/resources/assets/js/components/NotificationCard.vue @@ -57,6 +57,16 @@ {{truncate(n.account.username)}} updated a modlog.

+
+

+ {{truncate(n.account.username)}} tagged you in a post. +

+
+
+

+ We cannot display this notification at this time. +

+
{{timeAgo(n.created_at)}}
From 524c6d45585007585587efbd8907500d87e24dbe Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:08:47 -0600 Subject: [PATCH 09/31] Add MediaTagService --- app/Services/MediaTagService.php | 78 ++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 app/Services/MediaTagService.php diff --git a/app/Services/MediaTagService.php b/app/Services/MediaTagService.php new file mode 100644 index 000000000..087487d44 --- /dev/null +++ b/app/Services/MediaTagService.php @@ -0,0 +1,78 @@ +addMinutes(60), function() use($mediaId, $usernames) { + $key = self::CACHE_KEY . $mediaId; + if(Redis::zCount($key, '-inf', '+inf') == 0) { + return []; + } + $res = Redis::zRange($key, 0, -1); + if(!$usernames) { + return $res; + } + $usernames = []; + foreach ($res as $k) { + $username = (new self)->idToUsername($k); + array_push($usernames, $username); + } + + return $usernames; + }); + } + + public static function set($mediaId, $profileId) + { + $key = self::CACHE_KEY . $mediaId; + Redis::zAdd($key, $profileId, $profileId); + return true; + } + + protected function idToUsername($id) + { + $profile = ProfileService::build()->profileId($id); + + if(!$profile) { + return 'unavailable'; + } + + return [ + 'username' => $profile->username, + 'avatar' => $profile->avatarUrl() + ]; + } + + public static function sendNotification(MediaTag $tag) + { + $p = $tag->status->profile; + $actor = $p->username; + $message = "{$actor} tagged you in a post."; + $rendered = "{$actor} tagged you in a post."; + $n = new Notification; + $n->profile_id = $tag->profile_id; + $n->actor_id = $p->id; + $n->item_id = $tag->id; + $n->item_type = 'App\MediaTag'; + $n->action = 'tagged'; + $n->message = $message; + $n->rendered = $rendered; + $n->save(); + return; + } + +} \ No newline at end of file From af87bf503887f25442bb4036d075675ff3a054c0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:12:37 -0600 Subject: [PATCH 10/31] Update APFetchService --- app/Services/ActivityPubFetchService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/ActivityPubFetchService.php b/app/Services/ActivityPubFetchService.php index 765c62765..cdfe81438 100644 --- a/app/Services/ActivityPubFetchService.php +++ b/app/Services/ActivityPubFetchService.php @@ -14,7 +14,7 @@ class ActivityPubFetchService public $url; public $headers = [ 'Accept' => 'application/activity+json, application/json', - 'User-Agent' => 'PixelfedBot - https://pixelfed.org' + 'User-Agent' => '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')' ]; public static function queue() From b3b220b9b315fe80b71193e4df4c2493efe8fbf1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:15:18 -0600 Subject: [PATCH 11/31] Update StoryController, allow video stories --- app/Http/Controllers/StoryController.php | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/StoryController.php b/app/Http/Controllers/StoryController.php index 1e59fba2a..acbd3f51f 100644 --- a/app/Http/Controllers/StoryController.php +++ b/app/Http/Controllers/StoryController.php @@ -24,7 +24,7 @@ class StoryController extends Controller 'file' => function() { return [ 'required', - 'mimes:image/jpeg,image/png', + 'mimes:image/jpeg,image/png,video/mp4', 'max:' . config('pixelfed.max_photo_size'), ]; }, @@ -42,7 +42,7 @@ class StoryController extends Controller $story = new Story(); $story->duration = 3; $story->profile_id = $user->profile_id; - $story->type = 'photo'; + $story->type = Str::endsWith($photo->getMimeType(), 'mp4') ? 'video' :'photo'; $story->mime = $photo->getMimeType(); $story->path = $path; $story->local = true; @@ -65,7 +65,8 @@ class StoryController extends Controller $mimes = explode(',', config('pixelfed.media_types')); if(in_array($photo->getMimeType(), [ 'image/jpeg', - 'image/png' + 'image/png', + 'video/mp4' ]) == false) { abort(400, 'Invalid media type'); return; @@ -73,11 +74,13 @@ class StoryController extends Controller $storagePath = "public/_esm.t2/{$monthHash}/{$sid}/{$rid}"; $path = $photo->store($storagePath); - $fpath = storage_path('app/' . $path); - $img = Intervention::make($fpath); - $img->orientate(); - $img->save($fpath, config('pixelfed.image_quality')); - $img->destroy(); + if(in_array($photo->getMimeType(), ['image/jpeg','image/png',])) { + $fpath = storage_path('app/' . $path); + $img = Intervention::make($fpath); + $img->orientate(); + $img->save($fpath, config('pixelfed.image_quality')); + $img->destroy(); + } return $path; } @@ -164,7 +167,7 @@ class StoryController extends Controller ->map(function($s, $k) { return [ 'id' => (string) $s->id, - 'type' => 'photo', + 'type' => Str::endsWith($s->path, '.mp4') ? 'video' :'photo', 'length' => 3, 'src' => url(Storage::url($s->path)), 'preview' => null, @@ -198,7 +201,7 @@ class StoryController extends Controller $res = [ 'id' => (string) $story->id, - 'type' => 'photo', + 'type' => Str::endsWith($story->path, '.mp4') ? 'video' :'photo', 'length' => 3, 'src' => url(Storage::url($story->path)), 'preview' => null, @@ -233,7 +236,7 @@ class StoryController extends Controller ->map(function($s, $k) { return [ 'id' => $s->id, - 'type' => 'photo', + 'type' => Str::endsWith($s->path, '.mp4') ? 'video' :'photo', 'length' => 3, 'src' => url(Storage::url($s->path)), 'preview' => null, @@ -315,7 +318,7 @@ class StoryController extends Controller ->map(function($s, $k) { return [ 'id' => $s->id, - 'type' => 'photo', + 'type' => Str::endsWith($s->path, '.mp4') ? 'video' :'photo', 'length' => 3, 'src' => url(Storage::url($s->path)), 'preview' => null, From ee93f4598cc4a6cb62d935cbcfaca2f5602891ff Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:29:29 -0600 Subject: [PATCH 12/31] Update InternalApiController, add media tags --- .../Controllers/InternalApiController.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 5463c895a..764893259 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -10,6 +10,7 @@ use App\{ Follower, Like, Media, + MediaTag, Notification, Profile, StatusHashtag, @@ -30,6 +31,7 @@ use League\Fractal\Serializer\ArraySerializer; use League\Fractal\Pagination\IlluminatePaginatorAdapter; use Illuminate\Validation\Rule; use Illuminate\Support\Str; +use App\Services\MediaTagService; use App\Services\ModLogService; use App\Services\PublicTimelineService; @@ -258,7 +260,8 @@ class InternalApiController extends Controller 'cw' => 'nullable|boolean', 'visibility' => 'required|string|in:public,private,unlisted|min:2|max:10', 'place' => 'nullable', - 'comments_disabled' => 'nullable' + 'comments_disabled' => 'nullable', + 'tagged' => 'nullable' ]); if(config('costar.enabled') == true) { @@ -282,6 +285,7 @@ class InternalApiController extends Controller $mimes = []; $place = $request->input('place'); $cw = $request->input('cw'); + $tagged = $request->input('tagged'); foreach($medias as $k => $media) { if($k + 1 > config('pixelfed.max_album_length')) { @@ -328,6 +332,21 @@ class InternalApiController extends Controller $media->save(); } + foreach($tagged as $tg) { + $mt = new MediaTag; + $mt->status_id = $status->id; + $mt->media_id = $status->media->first()->id; + $mt->profile_id = $tg['id']; + $mt->tagged_username = $tg['name']; + $mt->is_public = true; // (bool) $tg['privacy'] ?? 1; + $mt->metadata = json_encode([ + '_v' => 1, + ]); + $mt->save(); + MediaTagService::set($mt->status_id, $mt->profile_id); + MediaTagService::sendNotification($mt); + } + $visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility; $cw = $profile->cw == true ? true : $cw; $status->is_nsfw = $cw; From 421ea0222f9e1201ea6b21e20a1de37da2bc9645 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 17:32:49 -0600 Subject: [PATCH 13/31] Update ComposeModal.vue, add media tagging --- .../assets/js/components/ComposeModal.vue | 119 ++++++++++++++++-- 1 file changed, 109 insertions(+), 10 deletions(-) diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index c72e85304..65eddaf50 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -254,9 +254,9 @@ - +
+

Tag people NEW

+

Add location

@@ -269,9 +269,10 @@

- Visibility: {{visibilityTag}} + Audience - Edit + {{visibilityTag}} +

@@ -293,7 +294,42 @@
-

This feature is not available yet.

+ + +

You can tag {{10 - taggedUsernames.length}} more {{taggedUsernames.length == 9 ? 'person' : 'people'}}!

+

Tagged People

+
+
+
+ +
+ {{tag.name}} +
+
+
+ + +
+
+
+

Search usernames to tag.

+
+
+

When you tag someone, they are sent a notification.
For more information on tagging, click here.

+
+
+

Tagging someone is like mentioning them, with the option to make it private between you.

+

+ You can choose to tag someone in public or private mode. Public mode will allow others to see who you tagged in the post and private mode tagged users will not be shown to others. +

@@ -538,6 +574,7 @@ export default { composeTextLength: 0, nsfw: false, filters: [], + currentFilter: false, ids: [], media: [], carouselCursor: 0, @@ -560,7 +597,6 @@ export default { zoom: 0 }, - taggedUsernames: false, namedPages: [ 'cropPhoto', 'tagPeople', @@ -573,9 +609,12 @@ export default { 'mediaMetadata', 'addToStory', 'editMedia', - 'cameraRoll' + 'cameraRoll', + 'tagPeopleHelp' ], - cameraRollMedia: [] + cameraRollMedia: [], + taggedUsernames: [], + taggedPeopleSearch: null } }, @@ -673,6 +712,7 @@ export default { toggleFilter(e, filter) { this.media[this.carouselCursor].filter_class = filter; + this.currentFilter = filter; }, deleteMedia() { @@ -727,7 +767,8 @@ export default { visibility: this.visibility, cw: this.nsfw, comments_disabled: this.commentsDisabled, - place: this.place + place: this.place, + tagged: this.taggedUsernames }; axios.post('/api/local/status/compose', data) .then(res => { @@ -766,6 +807,10 @@ export default { this.page = 2; break; + case 'tagPeopleHelp': + this.showTagCard(); + break; + default: this.namedPages.indexOf(this.page) != -1 ? this.page = 3 : this.page--; break; @@ -803,6 +848,15 @@ export default { break; case 2: + if(this.currentFilter) { + if(window.confirm('Are you sure you want to apply this filter?')) { + this.applyFilterToMedia(); + this.page++; + } + } else { + this.page++; + } + break; case 3: this.page++; break; @@ -823,6 +877,11 @@ export default { this.page = 'tagPeople'; }, + showTagHelpCard() { + this.pageTitle = 'About Tag People'; + this.page = 'tagPeopleHelp'; + }, + showLocationCard() { this.pageTitle = 'Add Location'; this.page = 'addLocation'; @@ -909,7 +968,47 @@ export default { this.cameraRollMedia = res.data; }); }, + applyFilterToMedia() { + // this is where the magic happens + }, + + tagSearch(input) { + if (input.length < 1) { return []; }; + let self = this; + let results = []; + return axios.get('/api/local/compose/tag/search', { + params: { + q: input + } + }).then(res => { + //return res.data; + return res.data.filter(d => { + return self.taggedUsernames.filter(r => { + return r.id == d.id; + }).length == 0; + }); + }); + }, + + getTagResultValue(result) { + return '@' + result.name; + }, + + onTagSubmitLocation(result) { + if(this.taggedUsernames.filter(r => { + return r.id == result.id; + }).length) { + return; + } + this.taggedUsernames.push(result); + this.$refs.autocomplete.value = ''; + return; + }, + + untagUsername(index) { + this.taggedUsernames.splice(index, 1); + } } } From 1b1abe7c20f0e7e1eace7e992c6668cc51c73113 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jul 2020 21:06:23 -0600 Subject: [PATCH 14/31] Update guest nav view --- resources/views/layouts/partial/noauthnav.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/layouts/partial/noauthnav.blade.php b/resources/views/layouts/partial/noauthnav.blade.php index 797f1362e..d01fb514e 100644 --- a/resources/views/layouts/partial/noauthnav.blade.php +++ b/resources/views/layouts/partial/noauthnav.blade.php @@ -1,4 +1,4 @@ -