From c9b59dd88a9aebd86809098934cd9f64d47cc9e7 Mon Sep 17 00:00:00 2001 From: trwnh Date: Fri, 28 Jun 2019 03:30:09 -0500 Subject: [PATCH 001/323] change aspect ratio of status video player since posts are 1:1 and not 16:9, this allows the player to scale to the entire post container, while the media auto-fits itself within the player. --- resources/assets/js/components/presenter/VideoPresenter.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/presenter/VideoPresenter.vue b/resources/assets/js/components/presenter/VideoPresenter.vue index dbe5535d..8e9f37f7 100644 --- a/resources/assets/js/components/presenter/VideoPresenter.vue +++ b/resources/assets/js/components/presenter/VideoPresenter.vue @@ -5,7 +5,7 @@

{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}

(click to show)

-
+
@@ -23,4 +23,4 @@ export default { props: ['status'], } - \ No newline at end of file + From 3cf30697c2f08f97bb411bcb4fcbcf5075b54bc4 Mon Sep 17 00:00:00 2001 From: trwnh Date: Fri, 28 Jun 2019 03:35:20 -0500 Subject: [PATCH 002/323] allow post-component to shrink to fit media forcing a min-height causes sizing issues --- resources/assets/js/components/PostComponent.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index f0be53b1..96a7f542 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -390,11 +390,6 @@ .postPresenterContainer { background: #fff; } - @media(min-width: 720px) { - .postPresenterContainer { - min-height: 600px; - } - } ::-webkit-scrollbar { width: 0px; background: transparent; From ff4a76dafc41a602b9b066f537d2cbaa2cd5ccce Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 29 Jun 2019 13:51:49 -0600 Subject: [PATCH 003/323] Update FederationController, fix host meta --- app/Http/Controllers/FederationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index cb65e99b..f4c162ca 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -179,7 +179,7 @@ class FederationController extends Controller abort_if(!config('federation.webfinger.enabled'), 404); $path = route('well-known.webfinger'); - $xml = ''; + $xml = ''; return response($xml)->header('Content-Type', 'application/xrd+xml'); } From 99ea1e40dde5468b42ffc4a0f838d6a457cb5333 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 29 Jun 2019 14:45:00 -0600 Subject: [PATCH 004/323] Update login --- resources/views/auth/login.blade.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index c09b128f..a0e23291 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -41,7 +41,10 @@
@@ -56,16 +59,14 @@
- - -
-
From f72201ebd35d93fac869e406e0f9c8677a669d13 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 29 Jun 2019 14:45:44 -0600 Subject: [PATCH 005/323] Update PostComponent.vue --- resources/assets/js/components/PostComponent.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 96a7f542..8ea58b59 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -390,6 +390,11 @@ .postPresenterContainer { background: #fff; } + @media(min-width: 720px) { + .postPresenterContainer { + min-height: 600px; + } + } ::-webkit-scrollbar { width: 0px; background: transparent; From 56c8cfc2f76aa2c38bb72119137873fd4a517a30 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 29 Jun 2019 22:27:26 -0600 Subject: [PATCH 006/323] Add Changelog --- CHANGELOG.md | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..2b4d34f2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,127 @@ +# Release Notes + +## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.9.4...dev) + + +## [v0.9.X (TBD)](https://github.com/pixelfed/pixelfed/compare/v0.9.4...dev) + +### Added +- Add StatusService [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [425ec91](https://github.com/pixelfed/pixelfed/commit/425ec91) +- Add PublicTimelineService [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [734e892](https://github.com/pixelfed/pixelfed/commit/734e892) +- Add RelationshipSettings trait [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [bf8340f](https://github.com/pixelfed/pixelfed/commit/bf8340f) +- Add Remote Follows [#1388](https://github.com/pixelfed/pixelfed/pull/1388) +- Add Relationship Settings [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [b10e03d](https://github.com/pixelfed/pixelfed/commit/b10e03d) +- Add Configuration Editor to Admin Dashboard [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [323dca1](https://github.com/pixelfed/pixelfed/commit/323dca1) +- Add Migration, adding profile_id to users table [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [bdfe633](https://github.com/pixelfed/pixelfed/commit/bdfe633) +- Add Media configuration [#1414](https://github.com/pixelfed/pixelfed/pull/1414) +- Add Content Warnings to comments [#1430](https://github.com/pixelfed/pixelfed/pull/1430), [42d81fc](https://github.com/pixelfed/pixelfed/commit/42d81fc) [8d4b3bd](https://github.com/pixelfed/pixelfed/commit/8d4b3bd) [73e162e4](https://github.com/pixelfed/pixelfed/commit/3e162e4) +- Add new rate limits [#1436](https://github.com/pixelfed/pixelfed/pull/1436) [1f1df2d](https://github.com/pixelfed/pixelfed/commit/1f1df2d) +- Add RegenerateThumbnails command to force thumbnail regeneration [#1437](https://github.com/pixelfed/pixelfed/pull/1437) [a3be4cd](https://github.com/pixelfed/pixelfed/commit/a3be4cd) +- Add Pages Editor to Admin Dashboard [#1438](https://github.com/pixelfed/pixelfed/pull/1438) [ef3e30d](https://github.com/pixelfed/pixelfed/commit/ef3e30d) [718375a](https://github.com/pixelfed/pixelfed/commit/718375a) [79524a0](https://github.com/pixelfed/pixelfed/commit/79524a0) [13ceef0](https://github.com/pixelfed/pixelfed/commit/13ceef0) [2fbcd6d](https://github.com/pixelfed/pixelfed/commit/2fbcd6d) [bb207a4](https://github.com/pixelfed/pixelfed/commit/bb207a4) [ef07e31](https://github.com/pixelfed/pixelfed/commit/ef07e31) [aca5114](https://github.com/pixelfed/pixelfed/commit/aca5114) [59fcfc2](https://github.com/pixelfed/pixelfed/commit/59fcfc2) [e3cfd81](https://github.com/pixelfed/pixelfed/commit/e3cfd81) [7ade78b](https://github.com/pixelfed/pixelfed/commit/7ade78b) [4539afa](https://github.com/pixelfed/pixelfed/commit/4539afa) [1dbfcae](https://github.com/pixelfed/pixelfed/commit/1dbfcae) + +### Changed +- Update SearchController, fix AP verb typo [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [dc8acf9](https://github.com/pixelfed/pixelfed/commit/dc8acf9) +- Update StatusTransformer, increase media cache ttl to 14 days [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [f35718b](https://github.com/pixelfed/pixelfed/commit/f35718b) +- Update webpack config, extract vendor librarys [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [b42db89](https://github.com/pixelfed/pixelfed/commit/b42db89) +- Update admin statuses view, make table header light [#1387](https://github.com/pixelfed/pixelfed/pull/1387), [44afcc7](https://github.com/pixelfed/pixelfed/commit/44afcc7) +- Update settings, move disable/delete to Security Settings [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [ca0d638](https://github.com/pixelfed/pixelfed/commit/ca0d638) +- Update Installer command [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [506dd8b](https://github.com/pixelfed/pixelfed/commit/506dd8b) +- Update UserObserver [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [4ee3d10](https://github.com/pixelfed/pixelfed/commit/4ee3d10) +- Update AuthLogin listener [#1388](https://github.com/pixelfed/pixelfed/pull/1388), [c27c751](https://github.com/pixelfed/pixelfed/commit/c27c751) [1e8b092](https://github.com/pixelfed/pixelfed/commit/1e8b092) +- Update Image Optimization to not store EXIF by default [#1414](https://github.com/pixelfed/pixelfed/pull/1414) +- Update Settings, hide OAuth/Developer pages when not enabled [#1413](https://github.com/pixelfed/pixelfed/pull/1413) +- Update Presenter Components, move alt tag and filters to `````` element [#1415](https://github.com/pixelfed/pixelfed/pull/1415) +- Update Api Controllers, add missing caption limit to ```composePost()``` and missing ```is_nsfw``` attribute to comment queries [#1429](https://github.com/pixelfed/pixelfed/pull/1429), [1cff278](https://github.com/pixelfed/pixelfed/commit/1cff278) +- Update instances admin view, add scan button to find new instances [#1436](https://github.com/pixelfed/pixelfed/pull/1436) [a94a3ee](https://github.com/pixelfed/pixelfed/commit/a94a3ee) +- Update registration page, add links to terms and privacy pages [#1488](https://github.com/pixelfed/pixelfed/pull/1488) + +### Removed +- Remove Classic Compose UI [#1434](https://github.com/pixelfed/pixelfed/pull/1434), [72bffd1](https://github.com/pixelfed/pixelfed/commit/72bffd1) [a2640af](https://github.com/pixelfed/pixelfed/commit/a2640af) +- + + +## [v0.9.4 (2019-06-03)](https://github.com/pixelfed/pixelfed/compare/v0.9.0...v0.9.4) + +PSA: Due to the removal of Google Recaptcha, a one-time manual intervention is required. Please try the following after installing with composer: + +``` +rm -rf bootstrap/cache/* +composer dump-autoload +php artisan config:cache +``` + +### Added +- Notification service +- Notification card on timeline +- Double-tap to like posts (no animation yet) +- Moderator Mode for timelines +- Emoji reaction bar +- Like and reply to comments +- Hello Loops! Short videos will now loop and be discoverable from the Discover page. +- Labs: Optional profile recommendations +- Labs: Show full caption instead of "read more" button +- Labs: Simple "distraction-free" timeline -- no buttons, just images and captions + +### Changed +- Refactored notification view into a Vue component +- Preparations for Circles, DMs, and other upcoming functionality +- Default limit of 7500 follows +- Default limit of 20 follows per hour +- Default limit of 5 mentions per comment/caption +- Default limit of 30 hashtags per comment/caption +- Default limit of 2 links per comment/caption +- Thumbnail info overlays on profiles should now scale down to small screens (#1234) +- Moment UI containers are now properly sized (#1236) +- Album posts now have contrast for next/prev arrows (#1238) +- Filter previews now fit the image instead of stretching it (#1239) + +### Removed +- Google Recaptcha is no longer supported (#1231) +- Lightbox has been deprecated in favor of double-tap-to-like; it will return as a dedicated button in the future (#1277) + + +## [v0.9.0 (2019-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.8.6...v0.9.0) + +### Added +- Allow users to delete existing profile photos. +- Preliminary support for managing developer tokens, as well as authorizing apps +- Unmute and unblock users more easily. Profiles now reflect muting/blocking status. +- Lazy-loading images with `loading="lazy"`, as supported in Blink +- Added Network Timeline which includes non-local posts +- Add broadcast events for real-time updates +- Compose view now shows upload progress bar +- You can now audit logged-in devices +- Added WIP installer +- Moment UI! This alternative profile view is less square and more full-width pictures. + +### Changed +- Allow admins to view reported private posts +- Show sensitivity and privacy/audience in status views +- Cleanup of legacy code +- `commentsDisabled` has been replaced with preliminary support for Litepub Capability Enforcement (LiCE) +- `rel="me"` now added to profile websites +- Posts from locked accounts now default to followers-only + +### Removed +- Removed identicons due to SVG compatibility issues with federation. New users will instead be assigned a default avatar. + + +## [v0.8.6 (2019-04-06)](https://github.com/pixelfed/pixelfed/compare/v0.8.5...v0.8.6) + +### Added +- Add COSTAR - Confirm Object Sentiment Transform and Reduce + +COSTAR is a filtering system that allows admins to define environment variables that will dynamically apply certain policies to posts of a defined scope, similar to Pleroma's MRF system. + +Scopes: +- Domain: apply to posts from a specific website +- Actor: apply to posts from a specific profile/user +- Keyword: apply to posts containing a specific string + +Policies: +- Block: Default blocks the defined scope +- CW: Automatically rewrites the scope to apply a warning +- Unlist: Removes the scope from public timelines + + + From f56123d954e74df0172c4ad61b53e340c6cc2126 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 29 Jun 2019 22:39:28 -0600 Subject: [PATCH 007/323] Add CONTRIBUTING.md --- CONTRIBUTING.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..e8b7d982 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing + +## Bug Reports +To encourage active collaboration, Pixelfed strongly encourages pull requests, not just bug reports. "Bug reports" may also be sent in the form of a pull request containing a failing test. + +However, if you file a bug report, your issue should contain a title and a clear description of the issue. You should also include as much relevant information as possible and a code sample that demonstrates the issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix. + +Remember, bug reports are created in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the bug report will automatically see any activity or that others will jump to fix it. Creating a bug report serves to help yourself and others start on the path of fixing the problem. + +## Core Development Discussion +Informal discussion regarding bugs, new features, and implementation of existing features takes place in the ```#pixelfed-dev``` channel on the Freenode IRC network. + +## Compiled Assets +If you are submitting a change that will affect a compiled file, such as most of the files in ```resources/assets/sass``` or ```resources/assets/js``` of the pixelfed/pixelfed repository, do not commit the compiled files. Due to their large size, they cannot realistically be reviewed by a maintainer. This could be exploited as a way to inject malicious code into Pixelfed. In order to defensively prevent this, all compiled files will be generated and committed by Pixelfed maintainers. + +## Security Vulnerabilities +If you discover a security vulnerability within Pixelfed, please send an email to Daniel Supernault at hello@pixelfed.org. All security vulnerabilities will be promptly addressed. \ No newline at end of file From ec18c80c13fd7030effa42f2f2bdc0009277d78e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 29 Jun 2019 22:41:52 -0600 Subject: [PATCH 008/323] Fix broken LoginTest --- tests/Feature/LoginTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index 750c4889..c076da00 100644 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -14,7 +14,7 @@ class LoginTest extends TestCase { $response = $this->get('login'); - $response->assertSee('Forgot Your Password?'); + $response->assertSee('Forgot Password'); } /** @test */ From 2d8b36191cc99cf4a82d3b4e00f14ceece559e39 Mon Sep 17 00:00:00 2001 From: monkeyless <52392953+monkeyless@users.noreply.github.com> Date: Mon, 1 Jul 2019 06:12:27 +0200 Subject: [PATCH 009/323] Add russian translations --- resources/lang/ru/helpcenter.php | 26 ++++++++++++++++++++++++++ resources/lang/ru/navmenu.php | 19 +++++++++++++++++++ resources/lang/ru/notification.php | 10 ++++++---- resources/lang/ru/profile.php | 9 ++++++++- resources/lang/ru/site.php | 18 ++++++++++++++++++ resources/lang/ru/timeline.php | 2 +- 6 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 resources/lang/ru/helpcenter.php create mode 100644 resources/lang/ru/navmenu.php create mode 100644 resources/lang/ru/site.php diff --git a/resources/lang/ru/helpcenter.php b/resources/lang/ru/helpcenter.php new file mode 100644 index 00000000..a15dee61 --- /dev/null +++ b/resources/lang/ru/helpcenter.php @@ -0,0 +1,26 @@ + 'Помощь', + 'whatsnew' => 'Что нового', + + 'gettingStarted' => 'Первые шаги', + 'sharingMedia' => 'Поделиться', + 'profile' => 'Профиль', + 'stories' => 'Истории', + 'hashtags' => 'Хэштэти', + 'discover' => 'Discover', + 'directMessages' => 'Личное сообщение', + 'timelines' => 'Ленты', + 'embed' => 'Вставить', + + 'communityGuidelines' => 'Правила сообщества', + 'whatIsTheFediverse' => 'Что такое fediverse?', + 'controllingVisibility' => 'Управление видимостью', + 'blockingAccounts' => 'Заблокированные аккаунты', + 'safetyTips' => 'Советы по безопасности', + 'reportSomething' => 'Пожаловаться', + 'dataPolicy' => 'Конфиденциальность' + +]; diff --git a/resources/lang/ru/navmenu.php b/resources/lang/ru/navmenu.php new file mode 100644 index 00000000..2946aa3b --- /dev/null +++ b/resources/lang/ru/navmenu.php @@ -0,0 +1,19 @@ + 'Поиск', + 'home' => 'Home', + 'local' => 'локальная', + 'network' => 'Сеть', + 'discover' => 'Discover', + 'viewMyProfile' => 'Локальная лента', + 'myTimeline' => 'Моя лента', + 'publicTimeline' => 'Глобальная лента', + 'remoteFollow' => 'Remote Follow', + 'settings' => 'Настройки', + 'admin' => 'Администрация', + 'logout' => 'Выйти', + 'directMessages' => 'Личные сообщения', + +]; diff --git a/resources/lang/ru/notification.php b/resources/lang/ru/notification.php index f503d804..53e023d6 100644 --- a/resources/lang/ru/notification.php +++ b/resources/lang/ru/notification.php @@ -1,8 +1,10 @@ 'оценил(а) Ваше фото.', - 'startedFollowingYou' => 'теперь подписан(а) на Вас.', - + 'likedPhoto' => 'оценил(-а) Ваш пост.', + 'likedComment' => 'оценил(-а) Ваш комментарий.', + 'startedFollowingYou' => 'теперь подписан(-а) на Вас.', + 'commented' => 'оставил(-а) комментарий под Вашим постом.', + 'mentionedYou' => 'упомянул(-а) Вас.', + 'shared' => 'поделился(-ась) Вашим постом.', ]; diff --git a/resources/lang/ru/profile.php b/resources/lang/ru/profile.php index 581a0b0a..dc482e1e 100644 --- a/resources/lang/ru/profile.php +++ b/resources/lang/ru/profile.php @@ -4,5 +4,12 @@ return [ 'emptyTimeline' => 'У этого пользователя пока нет ни одного поста!', 'emptyFollowers' => 'У этого пользователя пока нет подписчиков!', 'emptyFollowing' => 'Этот пользователь пока ни на кого не подписан!', - 'savedWarning' => 'Только можете видеть то, что сохранили', + 'emptySaved' => 'Вы еще не сохранили ни одного поста!', + 'savedWarning' => 'Только можете видеть сохранённые посты', + 'privateProfileWarning' => 'Эта учётная запись скрыта', + 'alreadyFollow' => 'Уже подписаны на :username?', + 'loginToSeeProfile' => 'что бы посмотреть их фото и видео.', + + 'status.disabled.header' => 'Учётная запись недоступна', + 'status.disabled.body' => 'Нам очень жаль, эта учётная запись недоступна на данный момент. Пожалуйста, попробуйте позже.', ]; diff --git a/resources/lang/ru/site.php b/resources/lang/ru/site.php new file mode 100644 index 00000000..c86536f7 --- /dev/null +++ b/resources/lang/ru/site.php @@ -0,0 +1,18 @@ + 'О нас', + 'help' => 'Помощь', + 'language' => 'Язык', + 'fediverse' => 'Fediverse', + 'opensource' => 'Open Source', + 'terms' => 'Правила', + 'privacy' => 'Конфиденциальность', + 'l10nWip' => 'Мы все еще работаем над локализацией', + 'currentLocale' => 'Выбранный язык', + 'selectLocale' => 'выберите один из поддерживаемых языков', + 'contact' => 'Контакт', + 'contact-us' => 'Связь с нами', + +]; diff --git a/resources/lang/ru/timeline.php b/resources/lang/ru/timeline.php index 3afae346..6276ac80 100644 --- a/resources/lang/ru/timeline.php +++ b/resources/lang/ru/timeline.php @@ -2,6 +2,6 @@ return [ - 'emptyPersonalTimeline' => 'Ваша лента записей пуста.', + 'emptyPersonalTimeline' => 'Ваша лента пуста.', ]; From 5ef7936b48950377bad907f2d05ab2b53df1c931 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:18:23 -0600 Subject: [PATCH 010/323] Update BaseApiController --- app/Http/Controllers/Api/BaseApiController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index a18efa5d..6fa1073f 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -59,14 +59,11 @@ class BaseApiController extends Controller $res = $this->fractal->createData($resource)->toArray(); } else { $this->validate($request, [ - 'page' => 'nullable|integer|min:1', + 'page' => 'nullable|integer|min:1|max:10', 'limit' => 'nullable|integer|min:1|max:10' ]); $limit = $request->input('limit') ?? 10; $page = $request->input('page') ?? 1; - if($page > 3) { - return response()->json([]); - } $end = (int) $page * $limit; $start = (int) $end - $limit; $res = NotificationService::get($pid, $start, $end); From 9d7943a9ded7e1368472c9da43145d62cdbba8bb Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:22:35 -0600 Subject: [PATCH 011/323] Add StatusHashtagTransformer --- .../Api/StatusHashtagTransformer.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/Transformer/Api/StatusHashtagTransformer.php diff --git a/app/Transformer/Api/StatusHashtagTransformer.php b/app/Transformer/Api/StatusHashtagTransformer.php new file mode 100644 index 00000000..a0874af7 --- /dev/null +++ b/app/Transformer/Api/StatusHashtagTransformer.php @@ -0,0 +1,35 @@ +hashtag; + $status = $statusHashtag->status; + $profile = $statusHashtag->profile; + + return [ + 'status' => [ + 'type' => $status->type, + 'url' => $status->url(), + 'thumb' => $status->thumb(), + 'sensitive' => (bool) $status->is_nsfw, + 'like_count' => $status->likes_count, + 'share_count' => $status->reblogs_count, + 'user' => [ + 'username' => $profile->username, + 'url' => $profile->url(), + ] + ], + 'hashtag' => [ + 'name' => $hashtag->name, + 'url' => $hashtag->url(), + ] + ]; + } +} From 468a4203ca223fba771688cafac247d41d6b210b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:27:27 -0600 Subject: [PATCH 012/323] Add StatusHashtagService --- app/Services/StatusHashtagService.php | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Services/StatusHashtagService.php diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php new file mode 100644 index 00000000..0c512072 --- /dev/null +++ b/app/Services/StatusHashtagService.php @@ -0,0 +1,73 @@ + 2000 ? 2000 : $stop; + $ids = Redis::zrangebyscore($key, $start, $stop); + if(empty($ids)) { + $ids = self::coldGet($id, $start, $stop); + } + foreach($ids as $statusId) { + $res->push(self::getStatus($statusId, $id)); + } + return $res; + } + + public static function coldGet($id, $start = 0, $stop = 2000) + { + $stop = $stop > 2000 ? 2000 : $stop; + $ids = StatusHashtag::whereHashtagId($id) + ->latest() + ->skip($start) + ->take($stop) + ->pluck('status_id'); + foreach($ids as $key) { + self::set($id, $key); + } + return $ids; + } + + public static function set($key, $val) + { + return Redis::zadd(self::CACHE_KEY . $key, $val, $val); + } + + public static function del($key) + { + return Redis::zrem(self::CACHE_KEY . $key, $val); + } + + public static function count($id) + { + return Redis::zcount(self::CACHE_KEY . $id, '-inf', '+inf'); + } + + public static function getStatus($statusId, $hashtagId) + { + return Cache::remember('pf:services:status-hashtag:post:'.$statusId.':hashtag:'.$hashtagId, now()->addMonths(3), function() use($statusId, $hashtagId) { + $statusHashtag = StatusHashtag::with('profile', 'status', 'hashtag') + ->whereStatusId($statusId) + ->whereHashtagId($hashtagId) + ->first(); + $fractal = new Fractal\Manager(); + $fractal->setSerializer(new ArraySerializer()); + $resource = new Fractal\Resource\Item($statusHashtag, new StatusHashtagTransformer()); + return $fractal->createData($resource)->toArray(); + }); + } +} \ No newline at end of file From 9d55d65b58392b6b780a871355a014247596221e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:38:26 -0600 Subject: [PATCH 013/323] Add StatusHashtagObserver --- app/Observers/StatusHashtagObserver.php | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 app/Observers/StatusHashtagObserver.php diff --git a/app/Observers/StatusHashtagObserver.php b/app/Observers/StatusHashtagObserver.php new file mode 100644 index 00000000..51832bcb --- /dev/null +++ b/app/Observers/StatusHashtagObserver.php @@ -0,0 +1,64 @@ +hashtag_id, $hashtag->status_id); + } + + /** + * Handle the notification "updated" event. + * + * @param \App\Notification $notification + * @return void + */ + public function updated(StatusHashtag $hashtag) + { + StatusHashtagService::set($hashtag->hashtag_id, $hashtag->status_id); + } + + /** + * Handle the notification "deleted" event. + * + * @param \App\Notification $notification + * @return void + */ + public function deleted(StatusHashtag $hashtag) + { + StatusHashtagService::del($hashtag->hashtag_id, $hashtag->status_id); + } + + /** + * Handle the notification "restored" event. + * + * @param \App\Notification $notification + * @return void + */ + public function restored(StatusHashtag $hashtag) + { + StatusHashtagService::set($hashtag->hashtag_id, $hashtag->status_id); + } + + /** + * Handle the notification "force deleted" event. + * + * @param \App\Notification $notification + * @return void + */ + public function forceDeleted(StatusHashtag $hashtag) + { + StatusHashtagService::del($hashtag->hashtag_id, $hashtag->status_id); + } +} From dea1e916cf6c39b7638d8977a09f612a3cb2fc52 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:39:00 -0600 Subject: [PATCH 014/323] Add StatusHashtag Observer to AppServiceProvider --- app/Providers/AppServiceProvider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index cf52e7fd..6bfe2945 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -5,11 +5,13 @@ namespace App\Providers; use App\Observers\{ AvatarObserver, NotificationObserver, + StatusHashtagObserver, UserObserver }; use App\{ Avatar, Notification, + StatusHashtag, User }; use Auth, Horizon, URL; @@ -31,6 +33,7 @@ class AppServiceProvider extends ServiceProvider Avatar::observe(AvatarObserver::class); Notification::observe(NotificationObserver::class); + StatusHashtag::observe(StatusHashtagObserver::class); User::observe(UserObserver::class); Horizon::auth(function ($request) { From 1980ec025d8c06d48350ded4000f9e3793bfb873 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:41:55 -0600 Subject: [PATCH 015/323] Remove deprecated timeline views --- .../views/timeline/partial/new-form.blade.php | 82 ----------- resources/views/timeline/personal.blade.php | 68 --------- resources/views/timeline/public.blade.php | 59 -------- resources/views/timeline/template.blade.php | 132 ------------------ 4 files changed, 341 deletions(-) delete mode 100644 resources/views/timeline/partial/new-form.blade.php delete mode 100644 resources/views/timeline/personal.blade.php delete mode 100644 resources/views/timeline/public.blade.php delete mode 100644 resources/views/timeline/template.blade.php diff --git a/resources/views/timeline/partial/new-form.blade.php b/resources/views/timeline/partial/new-form.blade.php deleted file mode 100644 index 3dfd37e7..00000000 --- a/resources/views/timeline/partial/new-form.blade.php +++ /dev/null @@ -1,82 +0,0 @@ -
-
-
{{__('Create New Post')}}
-
-
- -
- @csrf - - -
-
- - -
- - Max Size: @maxFileSize(). Supported formats: jpeg, png, gif, bmp. Limited to {{config('pixelfed.max_album_length')}} photos per post. - -
-
- -

- 0 - / - {{config('pixelfed.max_caption_length')}} -

-
-
- -
-
- -
- -
- - Set the visibility of this post. - -
-
- -
- - -
- - Please mark all NSFW and controversial content, as per our content policy. - -
-
- -
- -
- - No filter selected. - -
-
- - -
-
-
- -
-
-
\ No newline at end of file diff --git a/resources/views/timeline/personal.blade.php b/resources/views/timeline/personal.blade.php deleted file mode 100644 index 016727e5..00000000 --- a/resources/views/timeline/personal.blade.php +++ /dev/null @@ -1,68 +0,0 @@ -@extends('layouts.app') - -@push('scripts') - -@endpush - -@section('content') - -
-
- @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - - @include('timeline.partial.new-form') - -
- @foreach($timeline as $item) - - @include('status.template') - - @endforeach - @if($timeline->count() == 0) -
-
-
-

{{ __('timeline.emptyPersonalTimeline') }}

-
-
-
- @endif -
- - - -
- {{$timeline->links()}} -
- -
-
- - -@endsection diff --git a/resources/views/timeline/public.blade.php b/resources/views/timeline/public.blade.php deleted file mode 100644 index a84e54bd..00000000 --- a/resources/views/timeline/public.blade.php +++ /dev/null @@ -1,59 +0,0 @@ -@extends('layouts.app') - -@push('scripts') - -@endpush - -@section('content') - -
-
- @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - - @include('timeline.partial.new-form') - -
- @foreach($timeline as $item) - - @include('status.template') - - @endforeach -
- - - -
- {{$timeline->links()}} -
- -
-
- - -@endsection diff --git a/resources/views/timeline/template.blade.php b/resources/views/timeline/template.blade.php deleted file mode 100644 index 83737a4d..00000000 --- a/resources/views/timeline/template.blade.php +++ /dev/null @@ -1,132 +0,0 @@ -@extends('layouts.app') - -@section('content') - - - -
-
-
- @if (session('status')) -
- {!! session('status') !!} -
- @endif - @if (session('error')) -
- {!! session('error') !!} -
- @endif - - -
- - @foreach($timeline as $item) - @if(is_null($item->in_reply_to_id)) - @include('status.template') - @endif - @endforeach - - @if($timeline->count() == 0) -
-
-
-

{{ __('timeline.emptyPersonalTimeline') }}

-
-
-
- @endif -
- - - -
- {{$timeline->links()}} -
- -
-
-
- - {{Auth::user()->username}}'s avatar - -
-

@{{Auth::user()->username}}

-

{{Auth::user()->name}}

-
-
- -
- -
- - {{-- --}} - - -
-
-
- -@endsection - -@push('scripts') - -@endpush \ No newline at end of file From 09361db173744c57d6b32c3420dce5bfaa56aeaa Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 30 Jun 2019 22:49:44 -0600 Subject: [PATCH 016/323] Remove deprecated status views --- resources/views/status/show/album.blade.php | 104 ---------------- resources/views/status/show/photo.blade.php | 85 ------------- resources/views/status/show/sidebar.blade.php | 117 ------------------ resources/views/status/show/video.blade.php | 50 -------- resources/views/status/template.blade.php | 2 +- .../views/status/timeline/album.blade.php | 29 ----- .../views/status/timeline/photo.blade.php | 15 --- .../status/timeline/video-album.blade.php | 57 --------- .../views/status/timeline/video.blade.php | 19 --- 9 files changed, 1 insertion(+), 477 deletions(-) delete mode 100644 resources/views/status/show/album.blade.php delete mode 100644 resources/views/status/show/photo.blade.php delete mode 100644 resources/views/status/show/sidebar.blade.php delete mode 100644 resources/views/status/show/video.blade.php delete mode 100644 resources/views/status/timeline/album.blade.php delete mode 100644 resources/views/status/timeline/photo.blade.php delete mode 100644 resources/views/status/timeline/video-album.blade.php delete mode 100644 resources/views/status/timeline/video.blade.php diff --git a/resources/views/status/show/album.blade.php b/resources/views/status/show/album.blade.php deleted file mode 100644 index da71a6dc..00000000 --- a/resources/views/status/show/album.blade.php +++ /dev/null @@ -1,104 +0,0 @@ -@extends('layouts.app',['title' => $user->username . " posted a photo: " . $status->likes_count . " likes, " . $status->comments_count . " comments" ]) - -@section('content') - -
-
-
-
- -
- -
-
- {{$user->username}} -
-
-
- -
-
-
- @if($status->is_nsfw) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
- @endif - - @if($status->is_nsfw) -
- @endif -
- @include('status.show.sidebar') -
-
-
- -@endsection - -@push('meta') - - - -@endpush diff --git a/resources/views/status/show/photo.blade.php b/resources/views/status/show/photo.blade.php deleted file mode 100644 index 7c3f3456..00000000 --- a/resources/views/status/show/photo.blade.php +++ /dev/null @@ -1,85 +0,0 @@ -@extends('layouts.app',['title' => $user->username . " posted a photo: " . $status->likes_count . " likes, " . $status->comments_count . " comments" ]) - -@section('content') - -
-
-
-
- -
- -
-
- {{$user->username}} -
-
-
- -
-
-
- @if($status->is_nsfw && $status->media_count == 1) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
- - - -
- @elseif(!$status->is_nsfw && $status->media_count == 1) -
- -
- @endif -
- @include('status.show.sidebar') -
-
-
- -@endsection - -@push('meta') - - - -@endpush diff --git a/resources/views/status/show/sidebar.blade.php b/resources/views/status/show/sidebar.blade.php deleted file mode 100644 index e524cb98..00000000 --- a/resources/views/status/show/sidebar.blade.php +++ /dev/null @@ -1,117 +0,0 @@ -
-
- -
- -
-
- {{$user->username}} -
-
-
- -
-
-
-
-
-

- {{$status->profile->username}} - {!! $status->rendered ?? e($status->caption) !!} -

-

View all comments

-
- @foreach($replies as $item) -

- {{ str_limit($item->profile->username, 15)}} - {!! $item->rendered ?? e($item->caption) !!} {{$item->created_at->diffForHumans(null, true, true ,true)}} -

- @endforeach -
-
-
-
-
- @if(Auth::check()) -
- @csrf - - -
-

- - - @endif - -
- @csrf - - -
-
-
- - -
-
- -
diff --git a/resources/views/status/show/video.blade.php b/resources/views/status/show/video.blade.php deleted file mode 100644 index 5babc6f6..00000000 --- a/resources/views/status/show/video.blade.php +++ /dev/null @@ -1,50 +0,0 @@ -@extends('layouts.app',['title' => $user->username . " posted a photo: " . $status->likes_count . " likes, " . $status->comments_count . " comments" ]) - -@section('content') - -
-
-
- -
- @if($status->is_nsfw && $status->media_count == 1) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
-
- -
-
- @elseif(!$status->is_nsfw && $status->media_count == 1) -
- -
- @endif -
- @include('status.show.sidebar') -
-
-
- -@endsection - -@push('meta') - - - -@endpush diff --git a/resources/views/status/template.blade.php b/resources/views/status/template.blade.php index f9f66f23..ebdc292f 100644 --- a/resources/views/status/template.blade.php +++ b/resources/views/status/template.blade.php @@ -91,7 +91,7 @@ likes
-

+

{{$item->profile->username}} diff --git a/resources/views/status/timeline/album.blade.php b/resources/views/status/timeline/album.blade.php deleted file mode 100644 index f606d41c..00000000 --- a/resources/views/status/timeline/album.blade.php +++ /dev/null @@ -1,29 +0,0 @@ -@if($status->is_nsfw) - -@else -

-@endif \ No newline at end of file diff --git a/resources/views/status/timeline/photo.blade.php b/resources/views/status/timeline/photo.blade.php deleted file mode 100644 index 9009b5d7..00000000 --- a/resources/views/status/timeline/photo.blade.php +++ /dev/null @@ -1,15 +0,0 @@ -@if($status->is_nsfw) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
- - - -
-@else -
- -
-@endif \ No newline at end of file diff --git a/resources/views/status/timeline/video-album.blade.php b/resources/views/status/timeline/video-album.blade.php deleted file mode 100644 index 684bd2d3..00000000 --- a/resources/views/status/timeline/video-album.blade.php +++ /dev/null @@ -1,57 +0,0 @@ -@if($status->is_nsfw) - -@else - -@endif \ No newline at end of file diff --git a/resources/views/status/timeline/video.blade.php b/resources/views/status/timeline/video.blade.php deleted file mode 100644 index e0f4245e..00000000 --- a/resources/views/status/timeline/video.blade.php +++ /dev/null @@ -1,19 +0,0 @@ -@if($status->is_nsfw) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
-
- -
-
-@else -
- -
-@endif \ No newline at end of file From 7591eadbd19cea17d5fa47f87d33da1dc73452c2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Jul 2019 21:52:29 -0600 Subject: [PATCH 017/323] Update Hashtag limit --- app/Jobs/StatusPipeline/StatusEntityLexer.php | 3 +++ app/Util/Lexer/Extractor.php | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Jobs/StatusPipeline/StatusEntityLexer.php b/app/Jobs/StatusPipeline/StatusEntityLexer.php index ecad11e1..beda89bd 100644 --- a/app/Jobs/StatusPipeline/StatusEntityLexer.php +++ b/app/Jobs/StatusPipeline/StatusEntityLexer.php @@ -89,6 +89,9 @@ class StatusEntityLexer implements ShouldQueue $status = $this->status; foreach ($tags as $tag) { + if(mb_strlen($tag) > 124) { + continue; + } DB::transaction(function () use ($status, $tag) { $slug = str_slug($tag, '-', false); $hashtag = Hashtag::firstOrCreate( diff --git a/app/Util/Lexer/Extractor.php b/app/Util/Lexer/Extractor.php index 9e194b06..bcdbba91 100755 --- a/app/Util/Lexer/Extractor.php +++ b/app/Util/Lexer/Extractor.php @@ -264,7 +264,9 @@ class Extractor extends Regex if (preg_match(self::$patterns['end_hashtag_match'], $outer[0])) { continue; } - + if(mb_strlen($hashtag[0]) > 124) { + continue; + } $tags[] = [ 'hashtag' => $hashtag[0], 'indices' => [$start_position, $end_position], From 7ffb4c4a450be192f3563bae898edb191c37cb4f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Jul 2019 23:06:37 -0600 Subject: [PATCH 018/323] Update StatusHashtag model, add media relation --- app/StatusHashtag.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/StatusHashtag.php b/app/StatusHashtag.php index 15e28202..de67ebd6 100644 --- a/app/StatusHashtag.php +++ b/app/StatusHashtag.php @@ -26,4 +26,16 @@ class StatusHashtag extends Model { return $this->belongsTo(Profile::class); } + + public function media() + { + return $this->hasManyThrough( + Media::class, + Status::class, + 'id', + 'status_id', + 'status_id', + 'id' + ); + } } From 914b0e49657d25ae0c8ea792f3967b92d7ce9a2c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Jul 2019 23:13:43 -0600 Subject: [PATCH 019/323] Update StatusHashtagService --- app/Services/StatusHashtagService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php index 0c512072..4f876a68 100644 --- a/app/Services/StatusHashtagService.php +++ b/app/Services/StatusHashtagService.php @@ -32,6 +32,7 @@ class StatusHashtagService { { $stop = $stop > 2000 ? 2000 : $stop; $ids = StatusHashtag::whereHashtagId($id) + ->whereHas('media') ->latest() ->skip($start) ->take($stop) From 4f9a88a77f6aafa58f8a731eb184472f70d2b2af Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Jul 2019 23:14:01 -0600 Subject: [PATCH 020/323] Update StatusHashtagTransformer --- app/Transformer/Api/StatusHashtagTransformer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Transformer/Api/StatusHashtagTransformer.php b/app/Transformer/Api/StatusHashtagTransformer.php index a0874af7..62ccd2c7 100644 --- a/app/Transformer/Api/StatusHashtagTransformer.php +++ b/app/Transformer/Api/StatusHashtagTransformer.php @@ -12,12 +12,13 @@ class StatusHashtagTransformer extends Fractal\TransformerAbstract $hashtag = $statusHashtag->hashtag; $status = $statusHashtag->status; $profile = $statusHashtag->profile; - + return [ 'status' => [ 'type' => $status->type, 'url' => $status->url(), 'thumb' => $status->thumb(), + 'filter' => $status->firstMedia()->filter_class, 'sensitive' => (bool) $status->is_nsfw, 'like_count' => $status->likes_count, 'share_count' => $status->reblogs_count, From 58a19bbf0507cd988565f65ca54e6df71728e351 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 2 Jul 2019 00:33:58 -0600 Subject: [PATCH 021/323] Update StatusHashtagTransformer --- .../Api/StatusHashtagTransformer.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/Transformer/Api/StatusHashtagTransformer.php b/app/Transformer/Api/StatusHashtagTransformer.php index 62ccd2c7..afe1712f 100644 --- a/app/Transformer/Api/StatusHashtagTransformer.php +++ b/app/Transformer/Api/StatusHashtagTransformer.php @@ -15,21 +15,22 @@ class StatusHashtagTransformer extends Fractal\TransformerAbstract return [ 'status' => [ - 'type' => $status->type, - 'url' => $status->url(), - 'thumb' => $status->thumb(), - 'filter' => $status->firstMedia()->filter_class, - 'sensitive' => (bool) $status->is_nsfw, - 'like_count' => $status->likes_count, - 'share_count' => $status->reblogs_count, + 'id' => (int) $status->id, + 'type' => $status->type, + 'url' => $status->url(), + 'thumb' => $status->thumb(), + 'filter' => $status->firstMedia()->filter_class, + 'sensitive' => (bool) $status->is_nsfw, + 'like_count' => $status->likes_count, + 'share_count' => $status->reblogs_count, 'user' => [ 'username' => $profile->username, 'url' => $profile->url(), ] ], 'hashtag' => [ - 'name' => $hashtag->name, - 'url' => $hashtag->url(), + 'name' => $hashtag->name, + 'url' => $hashtag->url(), ] ]; } From 8a47b03a1b21a164e34ad76b15228009b349ec15 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 2 Jul 2019 00:34:28 -0600 Subject: [PATCH 022/323] Update StatusHashtagService --- app/Services/StatusHashtagService.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php index 4f876a68..76d0f47e 100644 --- a/app/Services/StatusHashtagService.php +++ b/app/Services/StatusHashtagService.php @@ -18,9 +18,14 @@ class StatusHashtagService { $res = collect([]); $key = self::CACHE_KEY . $id; $stop = $stop > 2000 ? 2000 : $stop; - $ids = Redis::zrangebyscore($key, $start, $stop); + $ids = Redis::zrevrangebyscore($key, $start, $stop); if(empty($ids)) { - $ids = self::coldGet($id, $start, $stop); + if(self::count($id) == 0) { + $ids = self::coldGet($id, 0, 2000); + $ids = $ids->splice($start, $stop); + } else { + $ids = self::coldGet($id, $start, $stop); + } } foreach($ids as $statusId) { $res->push(self::getStatus($statusId, $id)); From eab5fceb9fb4946f262fe209e61e8e99e8b9f8d2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 4 Jul 2019 20:05:28 -0600 Subject: [PATCH 023/323] Update StatusHashtagService --- app/Services/StatusHashtagService.php | 34 +++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php index 76d0f47e..1cfcf429 100644 --- a/app/Services/StatusHashtagService.php +++ b/app/Services/StatusHashtagService.php @@ -13,24 +13,18 @@ class StatusHashtagService { const CACHE_KEY = 'pf:services:status-hashtag:collection:'; - public static function get($id, $start = 0, $stop = 100) + public static function get($id, $page = 1, $stop = 9) { - $res = collect([]); - $key = self::CACHE_KEY . $id; - $stop = $stop > 2000 ? 2000 : $stop; - $ids = Redis::zrevrangebyscore($key, $start, $stop); - if(empty($ids)) { - if(self::count($id) == 0) { - $ids = self::coldGet($id, 0, 2000); - $ids = $ids->splice($start, $stop); - } else { - $ids = self::coldGet($id, $start, $stop); - } - } - foreach($ids as $statusId) { - $res->push(self::getStatus($statusId, $id)); - } - return $res; + return StatusHashtag::whereHashtagId($id) + ->whereHas('media') + ->skip($stop) + ->latest() + ->take(9) + ->pluck('status_id') + ->map(function ($i, $k) use ($id) { + return self::getStatus($i, $id); + }) + ->all(); } public static function coldGet($id, $start = 0, $stop = 2000) @@ -60,7 +54,11 @@ class StatusHashtagService { public static function count($id) { - return Redis::zcount(self::CACHE_KEY . $id, '-inf', '+inf'); + $count = Redis::zcount(self::CACHE_KEY . $id, '-inf', '+inf'); + if(empty($count)) { + $count = StatusHashtag::whereHashtagId($id)->count(); + } + return $count; } public static function getStatus($statusId, $hashtagId) From 6f783cac66b4d3e8ef116dc643ff06f792aea75f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 4 Jul 2019 20:21:20 -0600 Subject: [PATCH 024/323] Update DiscoverController --- app/Http/Controllers/DiscoverController.php | 72 ++++++--------------- 1 file changed, 21 insertions(+), 51 deletions(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index bbc8d765..0a4d67af 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -17,6 +17,7 @@ use App\Transformer\Api\StatusStatelessTransformer; use League\Fractal; use League\Fractal\Serializer\ArraySerializer; use League\Fractal\Pagination\IlluminatePaginatorAdapter; +use App\Services\StatusHashtagService; class DiscoverController extends Controller { @@ -37,56 +38,9 @@ class DiscoverController extends Controller public function showTags(Request $request, $hashtag) { abort_if(!Auth::check(), 403); - - $tag = Hashtag::whereSlug($hashtag) - ->firstOrFail(); - - $page = 1; - $key = 'discover:tag-'.$tag->id.':page-'.$page; - $keyMinutes = 15; - - $posts = Cache::remember($key, now()->addMinutes($keyMinutes), function() use ($tag, $request) { - $tags = StatusHashtag::select('status_id') - ->whereHashtagId($tag->id) - ->orderByDesc('id') - ->take(48) - ->pluck('status_id'); - - return Status::select( - 'id', - 'uri', - 'caption', - 'rendered', - 'profile_id', - 'type', - 'in_reply_to_id', - 'reblog_of_id', - 'is_nsfw', - 'scope', - 'local', - 'created_at', - 'updated_at' - )->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) - ->with('media') - ->whereLocal(true) - ->whereNull('uri') - ->whereIn('id', $tags) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->whereNull('url') - ->whereNull('uri') - ->withCount(['likes', 'comments']) - ->whereIsNsfw(false) - ->whereVisibility('public') - ->orderBy('id', 'desc') - ->get(); - }); - - if($posts->count() == 0) { - abort(404); - } - - return view('discover.tags.show', compact('tag', 'posts')); + $tag = Hashtag::whereSlug($hashtag)->firstOrFail(); + $tagCount = StatusHashtagService::count($tag->id); + return view('discover.tags.show', compact('tag', 'tagCount')); } public function showCategory(Request $request, $slug) @@ -156,7 +110,6 @@ class DiscoverController extends Controller return $res; } - public function loopWatch(Request $request) { abort_if(!Auth::check(), 403); @@ -171,4 +124,21 @@ class DiscoverController extends Controller return response()->json(200); } + + public function getHashtags(Request $request) + { + abort_if(!Auth::check(), 403); + $this->validate($request, [ + 'hashtag' => 'required|alphanum|min:2|max:124', + 'page' => 'nullable|integer|min:1|max:19' + ]); + + $page = $request->input('page') ?? '1'; + $end = $page > 1 ? $page * 9 : 0; + $tag = $request->input('hashtag'); + + $hashtag = Hashtag::whereName($tag)->firstOrFail(); + $res = StatusHashtagService::get($hashtag->id, $page, $end); + return $res; + } } From 9ccada5b0b72f7599cac7cee8d232efc9db305f0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 4 Jul 2019 21:19:29 -0600 Subject: [PATCH 025/323] Update CW for comments --- resources/assets/js/components/PostComponent.vue | 11 +++++++---- resources/assets/js/components/PostMenu.vue | 14 ++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 8ea58b59..a0f786fa 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -124,10 +124,13 @@
-
-

This comment may contain sensitive material

-

Show

-
+ + {{truncate(reply.account.username,15)}} + + This comment may contain sensitive material + Show + +

diff --git a/resources/assets/js/components/PostMenu.vue b/resources/assets/js/components/PostMenu.vue index dc5ab093..b219978a 100644 --- a/resources/assets/js/components/PostMenu.vue +++ b/resources/assets/js/components/PostMenu.vue @@ -6,8 +6,8 @@