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 .
+
+
{{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 .
+
+
+
+ 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 @@
-
+
Add location
@@ -269,9 +269,10 @@
@@ -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.privacy ? 'Public' : 'Private'}}
+
+
+
+
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 @@
-
+
From cc494fd14268cacf491d5c4c32024e2e52022ca8 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Tue, 14 Jul 2020 21:06:54 -0600
Subject: [PATCH 15/31] Update profiles.home view
---
resources/views/discover/profiles/home.blade.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/resources/views/discover/profiles/home.blade.php b/resources/views/discover/profiles/home.blade.php
index 009a004ce..42daa88df 100644
--- a/resources/views/discover/profiles/home.blade.php
+++ b/resources/views/discover/profiles/home.blade.php
@@ -11,7 +11,6 @@
@endsection
@push('scripts')
-
@endpush
\ No newline at end of file
From 9db71f8b779f77391bb9eef46ae7a487da54d85e Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Tue, 14 Jul 2020 21:08:08 -0600
Subject: [PATCH 16/31] Update helpcenter lang
---
resources/lang/en/helpcenter.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/resources/lang/en/helpcenter.php b/resources/lang/en/helpcenter.php
index 62877d1a2..74531d7be 100644
--- a/resources/lang/en/helpcenter.php
+++ b/resources/lang/en/helpcenter.php
@@ -21,6 +21,8 @@ return [
'blockingAccounts' => 'Blocking Accounts',
'safetyTips' => 'Safety Tips',
'reportSomething' => 'Report Something',
- 'dataPolicy' => 'Data Policy'
+ 'dataPolicy' => 'Data Policy',
+
+ 'taggingPeople' => 'Tagging People'
];
\ No newline at end of file
From 49dab6fb5a0fbc1b84f5c6f4cfb21d1ceee09cad Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Wed, 15 Jul 2020 10:37:37 -0600
Subject: [PATCH 17/31] Update NotificationTransformer, add modlog and tagged
types
---
.../Api/NotificationTransformer.php | 24 +++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/app/Transformer/Api/NotificationTransformer.php b/app/Transformer/Api/NotificationTransformer.php
index 7d0d9c5e4..812b250e6 100644
--- a/app/Transformer/Api/NotificationTransformer.php
+++ b/app/Transformer/Api/NotificationTransformer.php
@@ -14,7 +14,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
'account',
'status',
'relationship',
- 'modlog'
+ 'modlog',
+ 'tagged'
];
public function transform(Notification $notification)
@@ -55,7 +56,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
'share' => 'share',
'like' => 'favourite',
'comment' => 'comment',
- 'admin.user.modlog.comment' => 'modlog'
+ 'admin.user.modlog.comment' => 'modlog',
+ 'tagged' => 'tagged'
];
return $verbs[$verb];
}
@@ -85,4 +87,22 @@ class NotificationTransformer extends Fractal\TransformerAbstract
return null;
}
}
+
+
+ public function includeTagged(Notification $notification)
+ {
+ $n = $notification;
+ if($n->item_id && $n->item_type == 'App\MediaTag') {
+ $ml = $n->item;
+ $res = $this->item($ml, function($ml) {
+ return [
+ 'username' => $ml->status->profile->username,
+ 'post_url' => $ml->status->url()
+ ];
+ });
+ return $res;
+ } else {
+ return null;
+ }
+ }
}
From 5452c02979b17f9204f66ba5afb37db1868dd0d6 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Sat, 18 Jul 2020 17:51:10 -0600
Subject: [PATCH 18/31] Update web routes
---
routes/web.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/routes/web.php b/routes/web.php
index 79f40a83c..e579d3164 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -186,6 +186,8 @@ 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::group(['prefix' => 'admin'], function () {
Route::post('moderate', 'Api\AdminApiController@moderate');
From a327f5c167da6a43bba756f821dee0f9a7cad82e Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Sat, 18 Jul 2020 17:53:40 -0600
Subject: [PATCH 19/31] Add HashidService
---
app/Services/HashidService.php | 50 ++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 app/Services/HashidService.php
diff --git a/app/Services/HashidService.php b/app/Services/HashidService.php
new file mode 100644
index 000000000..d23c5c52d
--- /dev/null
+++ b/app/Services/HashidService.php
@@ -0,0 +1,50 @@
+ PHP_INT_MAX || strlen($id) < self::MIN_LIMIT) {
+ return null;
+ }
+ $key = "hashids:{$id}";
+ return Cache::remember($key, now()->hours(48), function() use($id) {
+ $cmap = self::CMAP;
+ $base = strlen($cmap);
+ $shortcode = '';
+ while($id) {
+ $id = ($id - ($r = $id % $base)) / $base;
+ $shortcode = $cmap{$r} . $shortcode;
+ };
+ return $shortcode;
+ });
+ }
+
+ public static function decode($short)
+ {
+ $len = strlen($short);
+ if($len < 3 || $len > 11) {
+ return null;
+ }
+ $id = 0;
+ foreach(str_split($short) as $needle) {
+ $pos = strpos(self::CMAP, $needle);
+ // if(!$pos) {
+ // return null;
+ // }
+ $id = ($id*64) + $pos;
+ }
+ if(strlen($id) < self::MIN_LIMIT) {
+ return null;
+ }
+ return $id;
+ }
+
+}
\ No newline at end of file
From f34977d9a8e73aa8a8fc8886354ec9fcbae7a564 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Mon, 20 Jul 2020 08:32:16 -0600
Subject: [PATCH 20/31] Update StatusController, add shortcodeRedirect method
---
app/Http/Controllers/StatusController.php | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php
index cf209bf15..5ec19aa25 100644
--- a/app/Http/Controllers/StatusController.php
+++ b/app/Http/Controllers/StatusController.php
@@ -17,6 +17,7 @@ use Illuminate\Http\Request;
use League\Fractal;
use App\Util\Media\Filter;
use Illuminate\Support\Str;
+use App\Services\HashidService;
class StatusController extends Controller
{
@@ -65,6 +66,16 @@ class StatusController extends Controller
return view($template, compact('user', 'status'));
}
+ public function shortcodeRedirect(Request $request, $id)
+ {
+ if(strlen($id) < 5 || !Auth::check()) {
+ return redirect('/login?next='.urlencode('/' . $request->path()));
+ }
+ $id = HashidService::decode($id);
+ $status = Status::findOrFail($id);
+ return redirect($status->url());
+ }
+
public function showId(int $id)
{
abort(404);
From 78f37273e9afaddb87dfd802e31aa2d5b72a262c Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Mon, 20 Jul 2020 08:33:03 -0600
Subject: [PATCH 21/31] Update web routes
---
routes/web.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/routes/web.php b/routes/web.php
index e579d3164..d305143de 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -441,6 +441,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
});
Route::get('stories/{username}', 'ProfileController@stories');
+ Route::get('p/{id}', 'StatusController@shortcodeRedirect');
Route::get('c/{collection}', 'CollectionController@show');
Route::get('p/{username}/{id}/c', 'CommentController@showAll');
Route::get('p/{username}/{id}/embed', 'StatusController@showEmbed');
From 6e507a553a84ce380a92805bd11cc883cb3380c8 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Mon, 20 Jul 2020 08:34:51 -0600
Subject: [PATCH 22/31] Update StatusTransformer, add tagged and shortcode
fields
---
app/Transformer/Api/StatusTransformer.php | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/app/Transformer/Api/StatusTransformer.php b/app/Transformer/Api/StatusTransformer.php
index 80074e7b8..5eca1cca6 100644
--- a/app/Transformer/Api/StatusTransformer.php
+++ b/app/Transformer/Api/StatusTransformer.php
@@ -5,6 +5,8 @@ namespace App\Transformer\Api;
use App\Status;
use League\Fractal;
use Cache;
+use App\Services\HashidService;
+use App\Services\MediaTagService;
class StatusTransformer extends Fractal\TransformerAbstract
{
@@ -15,12 +17,15 @@ class StatusTransformer extends Fractal\TransformerAbstract
public function transform(Status $status)
{
+ $taggedPeople = MediaTagService::get($status->id);
+
return [
'id' => (string) $status->id,
+ 'shortcode' => HashidService::encode($status->id),
'uri' => $status->url(),
'url' => $status->url(),
- 'in_reply_to_id' => $status->in_reply_to_id,
- 'in_reply_to_account_id' => $status->in_reply_to_profile_id,
+ 'in_reply_to_id' => (string) $status->in_reply_to_id,
+ 'in_reply_to_account_id' => (string) $status->in_reply_to_profile_id,
'reblog' => null,
'content' => $status->rendered ?? $status->caption,
'content_text' => $status->caption,
@@ -50,6 +55,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
'parent' => [],
'place' => $status->place,
'local' => (bool) $status->local,
+ 'taggedPeople' => $taggedPeople
];
}
From 3f2decd5e3caf315e6f6b48d3b346b39d46062a4 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Mon, 20 Jul 2020 08:39:17 -0600
Subject: [PATCH 23/31] Update changelog
---
CHANGELOG.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3711fcb43..0598aab8e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
- 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))
+- Add MediaTagService ([524c6d45](https://github.com/pixelfed/pixelfed/commit/524c6d45))
### Updated
- Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc))
@@ -63,6 +64,11 @@
- 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))
+- Updated notification components, add modlog and tagged notification types ([51862b8b](https://github.com/pixelfed/pixelfed/commit/51862b8b))
+- Updated StoryController, allow video stories. ([b3b220b9](https://github.com/pixelfed/pixelfed/commit/b3b220b9))
+- Updated InternalApiController, add media tags. ([ee93f459](https://github.com/pixelfed/pixelfed/commit/ee93f459))
+- Updated ComposeModal.vue, add media tagging. ([421ea022](https://github.com/pixelfed/pixelfed/commit/421ea022))
+- Updated NotificationTransformer, add modlog and tagged types. ([49dab6fb](https://github.com/pixelfed/pixelfed/commit/49dab6fb))
## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
### Added
From 692d3c8d1b5e3bc36d471b2d06f305656f0684e5 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Mon, 20 Jul 2020 08:39:48 -0600
Subject: [PATCH 24/31] Update AP Helpers
---
app/Util/ActivityPub/Helpers.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php
index ef13e7b70..bd5bc95b1 100644
--- a/app/Util/ActivityPub/Helpers.php
+++ b/app/Util/ActivityPub/Helpers.php
@@ -24,6 +24,7 @@ use App\Jobs\StatusPipeline\NewStatusPipeline;
use App\Util\ActivityPub\HttpSignature;
use Illuminate\Support\Str;
use App\Services\ActivityPubDeliveryService;
+use App\Services\MediaPathService;
class Helpers {
@@ -355,9 +356,7 @@ class Helpers {
}
$attachments = isset($data['object']) ? $data['object']['attachment'] : $data['attachment'];
$user = $status->profile;
- $monthHash = hash('sha1', date('Y').date('m'));
- $userHash = hash('sha1', $user->id.(string) $user->created_at);
- $storagePath = "public/m/{$monthHash}/{$userHash}";
+ $storagePath = MediaPathService::get($user, 2);
$allowed = explode(',', config('pixelfed.media_types'));
foreach($attachments as $media) {
From bafe52efbb60bdae8cc420d0d46dc3fb6aa38828 Mon Sep 17 00:00:00 2001
From: Daniel Supernault
Date: Mon, 20 Jul 2020 08:50:59 -0600
Subject: [PATCH 25/31] Update PostComponent, add tagged modal
---
.../assets/js/components/PostComponent.vue | 133 +++++++++++-------
1 file changed, 85 insertions(+), 48 deletions(-)
diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue
index 38e01e151..9b74c8663 100644
--- a/resources/assets/js/components/PostComponent.vue
+++ b/resources/assets/js/components/PostComponent.vue
@@ -80,7 +80,7 @@