Merge pull request #4783 from pixelfed/staging

Update StoryApiV1Controller, add self-carousel endpoint. Fixes #4352
This commit is contained in:
daniel 2023-11-18 01:14:07 -07:00 committed by GitHub
commit 66dc955d11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 425 additions and 300 deletions

View file

@ -60,7 +60,7 @@
- Update HomeFeedPipeline, fix tag filtering ([f105f4e8](https://github.com/pixelfed/pixelfed/commit/f105f4e8)) - Update HomeFeedPipeline, fix tag filtering ([f105f4e8](https://github.com/pixelfed/pixelfed/commit/f105f4e8))
- Update HashtagService, reduce cached_count cache ttl ([15f29f7d](https://github.com/pixelfed/pixelfed/commit/15f29f7d)) - Update HashtagService, reduce cached_count cache ttl ([15f29f7d](https://github.com/pixelfed/pixelfed/commit/15f29f7d))
- Update ApiV1Controller, fix include_reblogs param on timelines/home endpoint, and improve limit pagination logic ([287f903b](https://github.com/pixelfed/pixelfed/commit/287f903b)) - Update ApiV1Controller, fix include_reblogs param on timelines/home endpoint, and improve limit pagination logic ([287f903b](https://github.com/pixelfed/pixelfed/commit/287f903b))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - Update StoryApiV1Controller, add self-carousel endpoint. Fixes ([#4352](https://github.com/pixelfed/pixelfed/issues/4352)) ([bcb88d5b](https://github.com/pixelfed/pixelfed/commit/bcb88d5b))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9) ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)

View file

@ -24,358 +24,482 @@ use App\Http\Resources\StoryView as StoryViewResource;
class StoryApiV1Controller extends Controller class StoryApiV1Controller extends Controller
{ {
public function carousel(Request $request) const RECENT_KEY = 'pf:stories:recent-by-id:';
{ const RECENT_TTL = 300;
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
$pid = $request->user()->profile_id;
if(config('database.default') == 'pgsql') { public function carousel(Request $request)
$s = Story::select('stories.*', 'followers.following_id') {
->leftJoin('followers', 'followers.following_id', 'stories.profile_id') abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
->where('followers.profile_id', $pid) $pid = $request->user()->profile_id;
->where('stories.active', true)
->get();
} else {
$s = Story::select('stories.*', 'followers.following_id')
->leftJoin('followers', 'followers.following_id', 'stories.profile_id')
->where('followers.profile_id', $pid)
->where('stories.active', true)
->orderBy('id')
->get();
}
$nodes = $s->map(function($s) use($pid) { if(config('database.default') == 'pgsql') {
$profile = AccountService::get($s->profile_id, true); $s = Cache::remember(self::RECENT_KEY . $pid, self::RECENT_TTL, function() use($pid) {
if(!$profile || !isset($profile['id'])) { return Story::select('stories.*', 'followers.following_id')
return false; ->leftJoin('followers', 'followers.following_id', 'stories.profile_id')
} ->where('followers.profile_id', $pid)
->where('stories.active', true)
->map(function($s) {
$r = new \StdClass;
$r->id = $s->id;
$r->profile_id = $s->profile_id;
$r->type = $s->type;
$r->path = $s->path;
return $r;
})
->unique('profile_id');
});
} else {
$s = Cache::remember(self::RECENT_KEY . $pid, self::RECENT_TTL, function() use($pid) {
return Story::select('stories.*', 'followers.following_id')
->leftJoin('followers', 'followers.following_id', 'stories.profile_id')
->where('followers.profile_id', $pid)
->where('stories.active', true)
->orderBy('id')
->get();
});
}
return [ $nodes = $s->map(function($s) use($pid) {
'id' => (string) $s->id, $profile = AccountService::get($s->profile_id, true);
'pid' => (string) $s->profile_id, if(!$profile || !isset($profile['id'])) {
'type' => $s->type, return false;
'src' => url(Storage::url($s->path)), }
'duration' => $s->duration ?? 3,
'seen' => StoryService::hasSeen($pid, $s->id),
'created_at' => $s->created_at->format('c')
];
})
->filter()
->groupBy('pid')
->map(function($item) use($pid) {
$profile = AccountService::get($item[0]['pid'], true);
$url = $profile['local'] ? url("/stories/{$profile['username']}") :
url("/i/rs/{$profile['id']}");
return [
'id' => 'pfs:' . $profile['id'],
'user' => [
'id' => (string) $profile['id'],
'username' => $profile['username'],
'username_acct' => $profile['acct'],
'avatar' => $profile['avatar'],
'local' => $profile['local'],
'is_author' => $profile['id'] == $pid
],
'nodes' => $item,
'url' => $url,
'seen' => StoryService::hasSeen($pid, StoryService::latest($profile['id'])),
];
})
->sortBy('seen')
->values();
$res = [ return [
'self' => [], 'id' => (string) $s->id,
'nodes' => $nodes, 'pid' => (string) $s->profile_id,
]; 'type' => $s->type,
'src' => url(Storage::url($s->path)),
'duration' => $s->duration ?? 3,
'seen' => StoryService::hasSeen($pid, $s->id),
'created_at' => $s->created_at->format('c')
];
})
->filter()
->groupBy('pid')
->map(function($item) use($pid) {
$profile = AccountService::get($item[0]['pid'], true);
$url = $profile['local'] ? url("/stories/{$profile['username']}") :
url("/i/rs/{$profile['id']}");
return [
'id' => 'pfs:' . $profile['id'],
'user' => [
'id' => (string) $profile['id'],
'username' => $profile['username'],
'username_acct' => $profile['acct'],
'avatar' => $profile['avatar'],
'local' => $profile['local'],
'is_author' => $profile['id'] == $pid
],
'nodes' => $item,
'url' => $url,
'seen' => StoryService::hasSeen($pid, StoryService::latest($profile['id'])),
];
})
->sortBy('seen')
->values();
if(Story::whereProfileId($pid)->whereActive(true)->exists()) { $res = [
$selfStories = Story::whereProfileId($pid) 'self' => [],
->whereActive(true) 'nodes' => $nodes,
->get() ];
->map(function($s) use($pid) {
return [
'id' => (string) $s->id,
'type' => $s->type,
'src' => url(Storage::url($s->path)),
'duration' => $s->duration,
'seen' => true,
'created_at' => $s->created_at->format('c')
];
})
->sortBy('id')
->values();
$selfProfile = AccountService::get($pid, true);
$res['self'] = [
'user' => [
'id' => (string) $selfProfile['id'],
'username' => $selfProfile['acct'],
'avatar' => $selfProfile['avatar'],
'local' => $selfProfile['local'],
'is_author' => true
],
'nodes' => $selfStories, if(Story::whereProfileId($pid)->whereActive(true)->exists()) {
]; $selfStories = Story::whereProfileId($pid)
} ->whereActive(true)
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); ->get()
} ->map(function($s) use($pid) {
return [
'id' => (string) $s->id,
'type' => $s->type,
'src' => url(Storage::url($s->path)),
'duration' => $s->duration,
'seen' => true,
'created_at' => $s->created_at->format('c')
];
})
->sortBy('id')
->values();
$selfProfile = AccountService::get($pid, true);
$res['self'] = [
'user' => [
'id' => (string) $selfProfile['id'],
'username' => $selfProfile['acct'],
'avatar' => $selfProfile['avatar'],
'local' => $selfProfile['local'],
'is_author' => true
],
public function add(Request $request) 'nodes' => $selfStories,
{ ];
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); }
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
}
$this->validate($request, [ public function selfCarousel(Request $request)
'file' => function() { {
return [ abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
'required', $pid = $request->user()->profile_id;
'mimetypes:image/jpeg,image/png,video/mp4',
'max:' . config_cache('pixelfed.max_photo_size'),
];
},
'duration' => 'sometimes|integer|min:0|max:30'
]);
$user = $request->user(); if(config('database.default') == 'pgsql') {
$s = Cache::remember(self::RECENT_KEY . $pid, self::RECENT_TTL, function() use($pid) {
return Story::select('stories.*', 'followers.following_id')
->leftJoin('followers', 'followers.following_id', 'stories.profile_id')
->where('followers.profile_id', $pid)
->where('stories.active', true)
->map(function($s) {
$r = new \StdClass;
$r->id = $s->id;
$r->profile_id = $s->profile_id;
$r->type = $s->type;
$r->path = $s->path;
return $r;
})
->unique('profile_id');
});
} else {
$s = Cache::remember(self::RECENT_KEY . $pid, self::RECENT_TTL, function() use($pid) {
return Story::select('stories.*', 'followers.following_id')
->leftJoin('followers', 'followers.following_id', 'stories.profile_id')
->where('followers.profile_id', $pid)
->where('stories.active', true)
->orderBy('id')
->get();
});
}
$count = Story::whereProfileId($user->profile_id) $nodes = $s->map(function($s) use($pid) {
->whereActive(true) $profile = AccountService::get($s->profile_id, true);
->where('expires_at', '>', now()) if(!$profile || !isset($profile['id'])) {
->count(); return false;
}
if($count >= Story::MAX_PER_DAY) { return [
abort(418, 'You have reached your limit for new Stories today.'); 'id' => (string) $s->id,
} 'pid' => (string) $s->profile_id,
'type' => $s->type,
'src' => url(Storage::url($s->path)),
'duration' => $s->duration ?? 3,
'seen' => StoryService::hasSeen($pid, $s->id),
'created_at' => $s->created_at->format('c')
];
})
->filter()
->groupBy('pid')
->map(function($item) use($pid) {
$profile = AccountService::get($item[0]['pid'], true);
$url = $profile['local'] ? url("/stories/{$profile['username']}") :
url("/i/rs/{$profile['id']}");
return [
'id' => 'pfs:' . $profile['id'],
'user' => [
'id' => (string) $profile['id'],
'username' => $profile['username'],
'username_acct' => $profile['acct'],
'avatar' => $profile['avatar'],
'local' => $profile['local'],
'is_author' => $profile['id'] == $pid
],
'nodes' => $item,
'url' => $url,
'seen' => StoryService::hasSeen($pid, StoryService::latest($profile['id'])),
];
})
->sortBy('seen')
->values();
$photo = $request->file('file'); $selfProfile = AccountService::get($pid, true);
$path = $this->storeMedia($photo, $user); $res = [
'self' => [
'user' => [
'id' => (string) $selfProfile['id'],
'username' => $selfProfile['acct'],
'avatar' => $selfProfile['avatar'],
'local' => $selfProfile['local'],
'is_author' => true
],
$story = new Story(); 'nodes' => [],
$story->duration = $request->input('duration', 3); ],
$story->profile_id = $user->profile_id; 'nodes' => $nodes,
$story->type = Str::endsWith($photo->getMimeType(), 'mp4') ? 'video' :'photo'; ];
$story->mime = $photo->getMimeType();
$story->path = $path;
$story->local = true;
$story->size = $photo->getSize();
$story->bearcap_token = str_random(64);
$story->expires_at = now()->addMinutes(1440);
$story->save();
$url = $story->path; if(Story::whereProfileId($pid)->whereActive(true)->exists()) {
$selfStories = Story::whereProfileId($pid)
->whereActive(true)
->get()
->map(function($s) use($pid) {
return [
'id' => (string) $s->id,
'type' => $s->type,
'src' => url(Storage::url($s->path)),
'duration' => $s->duration,
'seen' => true,
'created_at' => $s->created_at->format('c')
];
})
->sortBy('id')
->values();
$res['self']['nodes'] = $selfStories;
}
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
}
$res = [ public function add(Request $request)
'code' => 200, {
'msg' => 'Successfully added', abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
'media_id' => (string) $story->id,
'media_url' => url(Storage::url($url)) . '?v=' . time(),
'media_type' => $story->type
];
return $res; $this->validate($request, [
} 'file' => function() {
return [
'required',
'mimetypes:image/jpeg,image/png,video/mp4',
'max:' . config_cache('pixelfed.max_photo_size'),
];
},
'duration' => 'sometimes|integer|min:0|max:30'
]);
public function publish(Request $request) $user = $request->user();
{
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [ $count = Story::whereProfileId($user->profile_id)
'media_id' => 'required', ->whereActive(true)
'duration' => 'required|integer|min:0|max:30', ->where('expires_at', '>', now())
'can_reply' => 'required|boolean', ->count();
'can_react' => 'required|boolean'
]);
$id = $request->input('media_id'); if($count >= Story::MAX_PER_DAY) {
$user = $request->user(); abort(418, 'You have reached your limit for new Stories today.');
$story = Story::whereProfileId($user->profile_id) }
->findOrFail($id);
$story->active = true; $photo = $request->file('file');
$story->duration = $request->input('duration', 10); $path = $this->storeMedia($photo, $user);
$story->can_reply = $request->input('can_reply');
$story->can_react = $request->input('can_react');
$story->save();
StoryService::delLatest($story->profile_id); $story = new Story();
StoryFanout::dispatch($story)->onQueue('story'); $story->duration = $request->input('duration', 3);
StoryService::addRotateQueue($story->id); $story->profile_id = $user->profile_id;
$story->type = Str::endsWith($photo->getMimeType(), 'mp4') ? 'video' :'photo';
$story->mime = $photo->getMimeType();
$story->path = $path;
$story->local = true;
$story->size = $photo->getSize();
$story->bearcap_token = str_random(64);
$story->expires_at = now()->addMinutes(1440);
$story->save();
return [ $url = $story->path;
'code' => 200,
'msg' => 'Successfully published',
];
}
public function delete(Request $request, $id) $res = [
{ 'code' => 200,
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); 'msg' => 'Successfully added',
'media_id' => (string) $story->id,
'media_url' => url(Storage::url($url)) . '?v=' . time(),
'media_type' => $story->type
];
$user = $request->user(); return $res;
}
$story = Story::whereProfileId($user->profile_id) public function publish(Request $request)
->findOrFail($id); {
$story->active = false; abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
$story->save();
StoryDelete::dispatch($story)->onQueue('story'); $this->validate($request, [
'media_id' => 'required',
'duration' => 'required|integer|min:0|max:30',
'can_reply' => 'required|boolean',
'can_react' => 'required|boolean'
]);
return [ $id = $request->input('media_id');
'code' => 200, $user = $request->user();
'msg' => 'Successfully deleted' $story = Story::whereProfileId($user->profile_id)
]; ->findOrFail($id);
}
public function viewed(Request $request) $story->active = true;
{ $story->duration = $request->input('duration', 10);
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); $story->can_reply = $request->input('can_reply');
$story->can_react = $request->input('can_react');
$story->save();
$this->validate($request, [ StoryService::delLatest($story->profile_id);
'id' => 'required|min:1', StoryFanout::dispatch($story)->onQueue('story');
]); StoryService::addRotateQueue($story->id);
$id = $request->input('id');
$authed = $request->user()->profile; return [
'code' => 200,
'msg' => 'Successfully published',
];
}
$story = Story::with('profile') public function delete(Request $request, $id)
->findOrFail($id); {
$exp = $story->expires_at; abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
$profile = $story->profile; $user = $request->user();
if($story->profile_id == $authed->id) { $story = Story::whereProfileId($user->profile_id)
return []; ->findOrFail($id);
} $story->active = false;
$story->save();
$publicOnly = (bool) $profile->followedBy($authed); StoryDelete::dispatch($story)->onQueue('story');
abort_if(!$publicOnly, 403);
$v = StoryView::firstOrCreate([ return [
'story_id' => $id, 'code' => 200,
'profile_id' => $authed->id 'msg' => 'Successfully deleted'
]); ];
}
if($v->wasRecentlyCreated) { public function viewed(Request $request)
Story::findOrFail($story->id)->increment('view_count'); {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
if($story->local == false) { $this->validate($request, [
StoryViewDeliver::dispatch($story, $authed)->onQueue('story'); 'id' => 'required|min:1',
} ]);
} $id = $request->input('id');
Cache::forget('stories:recent:by_id:' . $authed->id); $authed = $request->user()->profile;
StoryService::addSeen($authed->id, $story->id);
return ['code' => 200];
}
public function comment(Request $request) $story = Story::with('profile')
{ ->findOrFail($id);
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); $exp = $story->expires_at;
$this->validate($request, [
'sid' => 'required',
'caption' => 'required|string'
]);
$pid = $request->user()->profile_id;
$text = $request->input('caption');
$story = Story::findOrFail($request->input('sid')); $profile = $story->profile;
abort_if(!$story->can_reply, 422); if($story->profile_id == $authed->id) {
return [];
}
$status = new Status; $publicOnly = (bool) $profile->followedBy($authed);
$status->type = 'story:reply'; abort_if(!$publicOnly, 403);
$status->profile_id = $pid;
$status->caption = $text;
$status->rendered = $text;
$status->scope = 'direct';
$status->visibility = 'direct';
$status->in_reply_to_profile_id = $story->profile_id;
$status->entities = json_encode([
'story_id' => $story->id
]);
$status->save();
$dm = new DirectMessage; $v = StoryView::firstOrCreate([
$dm->to_id = $story->profile_id; 'story_id' => $id,
$dm->from_id = $pid; 'profile_id' => $authed->id
$dm->type = 'story:comment'; ]);
$dm->status_id = $status->id;
$dm->meta = json_encode([
'story_username' => $story->profile->username,
'story_actor_username' => $request->user()->username,
'story_id' => $story->id,
'story_media_url' => url(Storage::url($story->path)),
'caption' => $text
]);
$dm->save();
Conversation::updateOrInsert( if($v->wasRecentlyCreated) {
[ Story::findOrFail($story->id)->increment('view_count');
'to_id' => $story->profile_id,
'from_id' => $pid
],
[
'type' => 'story:comment',
'status_id' => $status->id,
'dm_id' => $dm->id,
'is_hidden' => false
]
);
if($story->local) { if($story->local == false) {
$n = new Notification; StoryViewDeliver::dispatch($story, $authed)->onQueue('story');
$n->profile_id = $dm->to_id; }
$n->actor_id = $dm->from_id; }
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:comment';
$n->save();
} else {
StoryReplyDeliver::dispatch($story, $status)->onQueue('story');
}
return [ Cache::forget('stories:recent:by_id:' . $authed->id);
'code' => 200, StoryService::addSeen($authed->id, $story->id);
'msg' => 'Sent!' return ['code' => 200];
]; }
}
protected function storeMedia($photo, $user) public function comment(Request $request)
{ {
$mimes = explode(',', config_cache('pixelfed.media_types')); abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
if(in_array($photo->getMimeType(), [ $this->validate($request, [
'image/jpeg', 'sid' => 'required',
'image/png', 'caption' => 'required|string'
'video/mp4' ]);
]) == false) { $pid = $request->user()->profile_id;
abort(400, 'Invalid media type'); $text = $request->input('caption');
return;
}
$storagePath = MediaPathService::story($user->profile); $story = Story::findOrFail($request->input('sid'));
$path = $photo->storePubliclyAs($storagePath, Str::random(random_int(2, 12)) . '_' . Str::random(random_int(32, 35)) . '_' . Str::random(random_int(1, 14)) . '.' . $photo->extension());
return $path;
}
public function viewers(Request $request) abort_if(!$story->can_reply, 422);
{
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [ $status = new Status;
'sid' => 'required|string|min:1|max:50' $status->type = 'story:reply';
]); $status->profile_id = $pid;
$status->caption = $text;
$status->rendered = $text;
$status->scope = 'direct';
$status->visibility = 'direct';
$status->in_reply_to_profile_id = $story->profile_id;
$status->entities = json_encode([
'story_id' => $story->id
]);
$status->save();
$pid = $request->user()->profile_id; $dm = new DirectMessage;
$sid = $request->input('sid'); $dm->to_id = $story->profile_id;
$dm->from_id = $pid;
$dm->type = 'story:comment';
$dm->status_id = $status->id;
$dm->meta = json_encode([
'story_username' => $story->profile->username,
'story_actor_username' => $request->user()->username,
'story_id' => $story->id,
'story_media_url' => url(Storage::url($story->path)),
'caption' => $text
]);
$dm->save();
$story = Story::whereProfileId($pid) Conversation::updateOrInsert(
->whereActive(true) [
->findOrFail($sid); 'to_id' => $story->profile_id,
'from_id' => $pid
],
[
'type' => 'story:comment',
'status_id' => $status->id,
'dm_id' => $dm->id,
'is_hidden' => false
]
);
$viewers = StoryView::whereStoryId($story->id) if($story->local) {
$n = new Notification;
$n->profile_id = $dm->to_id;
$n->actor_id = $dm->from_id;
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:comment';
$n->save();
} else {
StoryReplyDeliver::dispatch($story, $status)->onQueue('story');
}
return [
'code' => 200,
'msg' => 'Sent!'
];
}
protected function storeMedia($photo, $user)
{
$mimes = explode(',', config_cache('pixelfed.media_types'));
if(in_array($photo->getMimeType(), [
'image/jpeg',
'image/png',
'video/mp4'
]) == false) {
abort(400, 'Invalid media type');
return;
}
$storagePath = MediaPathService::story($user->profile);
$path = $photo->storePubliclyAs($storagePath, Str::random(random_int(2, 12)) . '_' . Str::random(random_int(32, 35)) . '_' . Str::random(random_int(1, 14)) . '.' . $photo->extension());
return $path;
}
public function viewers(Request $request)
{
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [
'sid' => 'required|string|min:1|max:50'
]);
$pid = $request->user()->profile_id;
$sid = $request->input('sid');
$story = Story::whereProfileId($pid)
->whereActive(true)
->findOrFail($sid);
$viewers = StoryView::whereStoryId($story->id)
->orderByDesc('id') ->orderByDesc('id')
->cursorPaginate(10); ->cursorPaginate(10);
return StoryViewResource::collection($viewers); return StoryViewResource::collection($viewers);
} }
} }

View file

@ -313,6 +313,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::group(['prefix' => 'stories'], function () use($middleware) { Route::group(['prefix' => 'stories'], function () use($middleware) {
Route::get('carousel', 'Stories\StoryApiV1Controller@carousel')->middleware($middleware); Route::get('carousel', 'Stories\StoryApiV1Controller@carousel')->middleware($middleware);
Route::get('self-carousel', 'Stories\StoryApiV1Controller@selfCarousel')->middleware($middleware);
Route::post('add', 'Stories\StoryApiV1Controller@add')->middleware($middleware); Route::post('add', 'Stories\StoryApiV1Controller@add')->middleware($middleware);
Route::post('publish', 'Stories\StoryApiV1Controller@publish')->middleware($middleware); Route::post('publish', 'Stories\StoryApiV1Controller@publish')->middleware($middleware);
Route::post('seen', 'Stories\StoryApiV1Controller@viewed')->middleware($middleware); Route::post('seen', 'Stories\StoryApiV1Controller@viewed')->middleware($middleware);