repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
mbin
github_2023
others
1,416
MbinOrg
jwr1
@@ -1,18 +1,23 @@ -# Mbin +<p align="center"> + <img src="docs/images/mbin.png" alt="Mbin logo" width="400"> +</p> +<p align="center"> + <a href="https://github.com/MbinOrg/mbin/actions/workflows/action.yaml?query=branch%3Amain"><img src="https://github.com/MbinOrg/mbin/actions/workflows/action.yaml/badge.svg?branc...
```suggestion > Mbin is focused on what the community wants. Pull requests can be merged by any repo maintainer with merge rights in GitHub. Discussions take place on [Matrix](https://matrix.to/#/#mbin:melroy.org) then _consensus_ has to be reached by the community. ```
mbin
github_2023
php
1,366
MbinOrg
melroy89
@@ -19,6 +19,8 @@ class ThemeSettingsController extends AbstractController public const KBIN_THEME = 'kbin_theme'; public const KBIN_FONT_SIZE = 'kbin_font_size'; public const KBIN_PAGE_WIDTH = 'kbin_page_width'; + public const MBIN_SHOW_USER_DOMAIN = 'kbin_show_users_domain';
should we also use `mbin` in the value of the key string? These are just cookie names anyways, so that should work.
mbin
github_2023
php
1,366
MbinOrg
melroy89
@@ -46,13 +67,46 @@ public function setConfiguration(ConfigurationInterface $configuration): void $this->config = $configuration; } - public function render( - Node $node, - ChildNodeRendererInterface $childRenderer, - ): HtmlElement { + public function render(Node $node, ChildNod...
```suggestion $this->logger->debug("Got node of class {c}: username: '{k}', title: '{t}', type: '{ty}', url: '{url}'", [ ``` ^^
mbin
github_2023
php
1,366
MbinOrg
melroy89
@@ -46,13 +67,46 @@ public function setConfiguration(ConfigurationInterface $configuration): void $this->config = $configuration; } - public function render( - Node $node, - ChildNodeRendererInterface $childRenderer, - ): HtmlElement { + public function render(Node $node, ChildNod...
maybe it's a good practice to add some documentation (comment) above large functions.
mbin
github_2023
php
1,366
MbinOrg
melroy89
@@ -71,8 +74,20 @@ public function doWork(MessageInterface $message): void $this->handlePrivateMessage($object); } elseif (\in_array($object['type'], $postTypes)) { $this->handleChain($object, $stickyIt); + if (method_exists($this->cache, 'invalidateTags')) ...
Maybe also try to document this function better at line 61. It's very large. With a lot of logic.
mbin
github_2023
others
1,366
MbinOrg
melroy89
@@ -20,6 +20,9 @@ {{ component('settings_row_switch', {label: 'show_related_entries'|trans, settingsKey: 'MBIN_GENERAL_SHOW_RELATED_ENTRIES', defaultValue: 'true'}) }} {{ component('settings_row_switch', {label: 'show_related_posts'|trans, settingsKey: 'MBIN_GENERAL_SHOW_RELATED_POSTS', defaultValue: ...
It seems that the rest of the components don't have a new line either. So maybe keep that consistent? Or add new lines everywhere?
mbin
github_2023
php
1,394
MbinOrg
BentiGorlich
@@ -0,0 +1,291 @@ +<?php + +declare(strict_types=1); + +namespace App\Command; + +use App\Entity\Entry; +use App\Entity\EntryComment; +use App\Entity\Post; +use App\Entity\PostComment; +use App\Entity\User; +use App\Service\EntryCommentManager; +use App\Service\EntryManager; +use App\Service\PostCommentManager; +use Ap...
```suggestion $this->deleteAllImages($output); // Except for user avatars and covers ```
mbin
github_2023
php
1,394
MbinOrg
BentiGorlich
@@ -0,0 +1,291 @@ +<?php + +declare(strict_types=1); + +namespace App\Command; + +use App\Entity\Entry; +use App\Entity\EntryComment; +use App\Entity\Post; +use App\Entity\PostComment; +use App\Entity\User; +use App\Service\EntryCommentManager; +use App\Service\EntryManager; +use App\Service\PostCommentManager; +use Ap...
I think this should just be in the query no matter the value of `$this->noActivity` right? Or you could just do a inner join instead of a left join and remove this condition
mbin
github_2023
php
1,394
MbinOrg
BentiGorlich
@@ -0,0 +1,291 @@ +<?php + +declare(strict_types=1); + +namespace App\Command; + +use App\Entity\Entry; +use App\Entity\EntryComment; +use App\Entity\Post; +use App\Entity\PostComment; +use App\Entity\User; +use App\Service\EntryCommentManager; +use App\Service\EntryManager; +use App\Service\PostCommentManager; +use Ap...
if you call `detachImage` with an image that is null this will throw an error. Same for all the other `...Manager->detachImage(` calls. Especially for the user one where you have to have the or in the query
mbin
github_2023
php
1,394
MbinOrg
BentiGorlich
@@ -0,0 +1,319 @@ +<?php + +declare(strict_types=1); + +namespace App\Command; + +use App\Entity\Entry; +use App\Entity\EntryComment; +use App\Entity\Post; +use App\Entity\PostComment; +use App\Entity\User; +use App\Service\EntryCommentManager; +use App\Service\EntryManager; +use App\Service\PostCommentManager; +use Ap...
I think it would be a good practice to check for the the variables, even if it is already checked down the line ```suggestion if (null !== $user->cover) { $this->userManager->detachCover($user); } if (null !== $user->avatar) { $this->userManager-...
mbin
github_2023
php
1,272
MbinOrg
melroy89
@@ -0,0 +1,223 @@ +<?php + +declare(strict_types=1); + +namespace App\Repository; + +use App\DTO\EntryDto; +use App\DTO\MagazineDto; +use App\DTO\PostDto; +use App\DTO\UserDto; +use App\Entity\Entry; +use App\Entity\EntryComment; +use App\Entity\Magazine; +use App\Entity\NotificationSettings; +use App\Entity\Post; +use...
This query looks very heavy. Did you perform benchmarks on this new query? We already have too many long duration queries, so hopefully this query is not taking long to execute? And I'm talking about a server with many users and magazines of course (a real world scenario).
mbin
github_2023
javascript
1,390
MbinOrg
melroy89
@@ -36,6 +36,19 @@ export default class extends Controller { } this.checkHeight(); + + // if in a list and the click is made via touch, open the post + if (!this.element.classList.contains('isSingle')) { + this.element.addEventListener('click', (e) => { + if (...
You might want to check that `link` is not null or undefined.. Yes I know, in the good case scenario this might be true..
mbin
github_2023
javascript
1,390
MbinOrg
melroy89
@@ -36,6 +36,24 @@ export default class extends Controller { } this.checkHeight(); + + // if in a list and the click is made via touch, open the post + if (!this.element.classList.contains('isSingle')) { + this.element.addEventListener('click', (e) => { + if (...
both `let` here and the `let` below can be `const` :)
mbin
github_2023
others
1,346
MbinOrg
melroy89
@@ -101,17 +101,27 @@ jobs: DATABASE_PORT: 5432 REDIS_HOST: valkey REDIS_PORT: 6379 - run: php bin/phpunit tests/Unit + run: php vendor/bin/paratest --passthru-php="'-d' 'memory_limit=192M'" tests/Unit
is the memory limit increase needed for a unit test? no right? You might want to add it to the functional test I guess..?
mbin
github_2023
php
1,377
MbinOrg
BentiGorlich
@@ -67,8 +67,10 @@ public function doWork(MessageInterface $message): void $payload = @json_decode($message->payload, true); if (null === $payload) { - $this->logger->warning('[ActivityHandler::doWork] Activity message from was empty: {json}, ignoring it', ['json' => json_encode($message-...
This will probably error if the string is less than 200 characters
mbin
github_2023
others
1,372
MbinOrg
BentiGorlich
@@ -929,12 +929,12 @@ new_users_need_approval: New users have to be approved by an admin before they c signup_requests: Signup requests application_text: Application text signup_requests_header: Signup Requests -signup_requests_paragraph: These users would like to join your server. They cannot log in until you've ap...
I'd keep the singular here
mbin
github_2023
others
1,372
MbinOrg
BentiGorlich
@@ -929,12 +929,12 @@ new_users_need_approval: New users have to be approved by an admin before they c signup_requests: Signup requests application_text: Application text signup_requests_header: Signup Requests -signup_requests_paragraph: These users would like to join your server. They cannot log in until you've ap...
```suggestion You will receive an email your signup request has been processed. ```
mbin
github_2023
php
1,258
MbinOrg
BentiGorlich
@@ -511,6 +519,10 @@ public function updateMagazine(string $actorUrl): ?Magazine return $magazine; } + if ($this->settingsManager->isBannedInstance($actorUrl)) { + return null; + }
This check is be redundant as this `updateActor` and `createMagazine` which both have the check already
mbin
github_2023
php
1,258
MbinOrg
BentiGorlich
@@ -337,6 +341,10 @@ public function updateUser(string $actorUrl): ?User return $user; } + if ($this->settingsManager->isBannedInstance($actorUrl)) { + return null; + }
This check is be redundant as this updateActor and createUser which both have the check already
mbin
github_2023
php
1,258
MbinOrg
BentiGorlich
@@ -161,6 +160,11 @@ public function findActorOrCreate(?string $actorUrlOrHandle): User|Magazine|null $actorUrl = $this->webfinger($actorUrl)->getProfileId(); } + // Check if the instance is banned + if ($this->settingsManager->isBannedInstance($actorUrl)) { + return nul...
This check should be pushed down to the line just before `$actor = $this->apHttpClient->getActorObject($actorUrl);`
mbin
github_2023
php
1,258
MbinOrg
BentiGorlich
@@ -173,6 +172,11 @@ public function findActorOrCreate(?string $actorUrlOrHandle): User|Magazine|null return $this->userRepository->findOneBy(['username' => $name]); } + // Check if the instance is banned + if ($this->settingsManager->isBannedInstance($actorUrl)) { + ret...
I think we should just throw a `InstanceBannedException`. This would make it behave the same way it did before. Most of the code would probably work fine if we returned `null`, but it would be a big change in the behavior...
mbin
github_2023
php
1,258
MbinOrg
garrettw
@@ -205,6 +205,11 @@ private function getActorCacheKey(string $apProfileId): string return 'ap_'.hash('sha256', $apProfileId); } + private function getCollectinCacheKey(string $apAddress): string
I think the function name is misspelled; “Collection” is missing the last “o”
mbin
github_2023
php
1,258
MbinOrg
garrettw
@@ -280,22 +285,37 @@ private function getActorObjectImpl(string $apProfileId): ?string return $response->getContent(false); } + /** + * Remove actor object from cache. + * + * @param string $apProfileId AP profile ID to remove from cache + */ public function invalidateActorObjec...
I don’t think this return type matches what is actually being returned
mbin
github_2023
others
1,300
MbinOrg
melroy89
@@ -81,6 +81,61 @@ jobs: SYMFONY_DEPRECATIONS_HELPER: disabled run: php bin/phpunit tests/Unit + integration-test: + runs-on: ubuntu-latest + container: + image: danger89/mbin-pipeline:1.2.0 + steps: + - uses: actions/checkout@v4 + + - name: Get Composer Cache Directory + ...
```suggestion image: valkey/valkey ``` If you believe in open source licenses :)
mbin
github_2023
others
1,280
MbinOrg
melroy89
@@ -346,3 +346,13 @@ Usage: ```bash php bin/console mbin:user:create [-r|--remove] [--admin] [--moderator] [--] <username> <email> <password> ``` + +### Update-Local-Domain + +This command will remove all remote posts from belonging to the local domain. This command is only relevant for instances +created before v1....
What is --?
mbin
github_2023
others
1,304
MbinOrg
BentiGorlich
@@ -48,14 +48,20 @@ max_parallel_maintenance_workers = 4 # You should *not* increase this value more than max_worker_processes max_parallel_workers = 16 -# Write ahead log sizes (unless you expect to write more than 1GB/hour of data in the DB) -max_wal_size = 8GB -min_wal_size = 2GB +# Boost transaction speeds and ...
I think 40 min and 30 GB is abit much for the default...
mbin
github_2023
others
1,266
MbinOrg
melroy89
@@ -20,7 +20,7 @@ EXIF_EXIFTOOL_TIMEOUT=10 Available cleaning modes are: -- `none`: no metadata cleaning would be done. -- `sanitize`: removes GPS and serial number metadata. this is the default for uploaded images. -- `scrub`: removes most of image metadata save for those needed for proper image rendering - and ...
Remove [This line needs improvement]?
mbin
github_2023
php
1,254
MbinOrg
BentiGorlich
@@ -741,16 +743,20 @@ private function handleMagazineFeaturedCollection(string $actorUrl, Magazine $ma if (!$alreadyPinned) { $existingEntry = $this->entryRepository->findOneBy(['apId' => $apId]); if ($existingEntry) { - ...
This has to be outside of the `if ($isString)` It can and should be behind its own `if (!$this->settingsManager->isBannedInstance($apId))`
mbin
github_2023
others
1,232
MbinOrg
melroy89
@@ -919,3 +921,15 @@ search_type_all: Threads + Microblogs search_type_entry: Threads search_type_post: Microblogs select_user: Choose a user +new_users_need_approval: New users have to be approved by an admin before they can log in. +applications: Applications +application_text: Application text +signup_requests_he...
```suggestion email_application_rejected_body: Thank you for your interest, but we regret to inform you that your registration request has been declined. ```
mbin
github_2023
others
1,232
MbinOrg
melroy89
@@ -919,3 +921,15 @@ search_type_all: Threads + Microblogs search_type_entry: Threads search_type_post: Microblogs select_user: Choose a user +new_users_need_approval: New users have to be approved by an admin before they can log in. +applications: Applications +application_text: Application text +signup_requests_he...
```suggestion email_application_pending: Your account requires admin approval before you can log in. ```
mbin
github_2023
others
1,232
MbinOrg
melroy89
@@ -919,3 +921,15 @@ search_type_all: Threads + Microblogs search_type_entry: Threads search_type_post: Microblogs select_user: Choose a user +new_users_need_approval: New users have to be approved by an admin before they can log in. +applications: Applications +application_text: Application text +signup_requests_he...
```suggestion email_verification_pending: Please verify your email address before you can log in. ```
mbin
github_2023
php
1,232
MbinOrg
melroy89
@@ -240,13 +240,24 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Visibil #[Column(type: 'string', nullable: false, options: ['default' => self::USER_TYPE_PERSON])] public string $type; + #[Column(type: 'string', nullable: true)] + public string $applicationText; + + #[...
In theory you could potentially end up with `isApproved` and `isRejected` set to true, since there is no guard against this incorrect state. Not sure how to prevent that.
mbin
github_2023
php
1,235
MbinOrg
melroy89
@@ -53,8 +59,21 @@ public function workWrapper(MessageInterface $message): void $this->doWork($message); $conn->commit(); } catch (InvalidApPostException $e) { + if (400 <= $e->responseCode && 500 > $e->responseCode && 429 !== $e->responseCode) { + $conn->rol...
Agreed, however, I would also like to enable debugging logging as an admin. Allowing to see which servers (domain + response body) are giving me invalid HTTP requests back. And try to understand why. So do you think it's also a good idea to add a debug print log?
mbin
github_2023
php
1,235
MbinOrg
melroy89
@@ -14,8 +16,12 @@ use App\Service\ActivityPubManager; use App\Service\SettingsManager; use Doctrine\ORM\EntityManagerInterface; +use Psr\Cache\InvalidArgumentException; use Psr\Log\LoggerInterface; use Symfony\Component\Messenger\Attribute\AsMessageHandler; +use Symfony\Component\Messenger\Exception\RecoverableMe...
Best practice would be to have a static constant variable defined for `429` error code, instead of a magic value. Allowing you to give it a name as well like `tooManyRequestsErrorCode` for example.
mbin
github_2023
php
1,235
MbinOrg
melroy89
@@ -53,8 +59,21 @@ public function workWrapper(MessageInterface $message): void $this->doWork($message); $conn->commit(); } catch (InvalidApPostException $e) { + if (400 <= $e->responseCode && 500 > $e->responseCode && 429 !== $e->responseCode) {
```suggestion if (400 <= $e->responseCode && 500 >= $e->responseCode && 429 !== $e->responseCode) { ``` Also equal to 500 errors right?
mbin
github_2023
others
1,221
MbinOrg
BentiGorlich
@@ -243,17 +248,24 @@ server { access_log /var/log/nginx/mbin_access.log if=$regularRequest; access_log /var/log/nginx/mbin_inbox.log if=$inboxRequest buffer=32k flush=5m; + open_file_cache max=1000 inactive=20s; + open_file_cache_valid 60s; + open_file_cache_min_uses 2; + open_file_...
Why http 1.1?
mbin
github_2023
php
1,180
MbinOrg
melroyvandenberg
@@ -42,6 +42,27 @@ public function __invoke(DeliverMessage $message): void $this->workWrapper($message); } + public function workWrapper(MessageInterface $message): void + { + $conn = $this->entityManager->getConnection(); + if (!$conn->isConnected()) { + $conn->connect();...
Also catch for this `InvalidApGetException` in advance now? Since I would like to introduce that at some point. ```suggestion } catch (InvalidApPostException|InvalidApGetException $e) { ```
mbin
github_2023
php
1,102
MbinOrg
BentiGorlich
@@ -529,16 +529,26 @@ private function getHeaders(string $url, User|Magazine $actor, ?array $body = nu $stringToSign = self::headersToSigningString($headers); $signedHeaders = implode(' ', array_map('strtolower', array_keys($headers))); $key = openssl_pkey_get_private($actor->privateKey); - ...
Should you return here (and at 2nd comment) or throw an exception so this won't get processed any further?
mbin
github_2023
php
1,102
MbinOrg
BentiGorlich
@@ -554,11 +564,23 @@ private function getInstanceHeaders(string $url, ?array $body = null, string $me $stringToSign = self::headersToSigningString($headers); $signedHeaders = implode(' ', array_map('strtolower', array_keys($headers))); $key = openssl_pkey_get_private($privateKey); - o...
2nd
mbin
github_2023
php
1,102
MbinOrg
BentiGorlich
@@ -318,7 +318,7 @@ private function getCollectionObjectImpl(string $apAddress): ?string // Accepted status code are 2xx or 410 (used Tombstone types) if (!str_starts_with((string) $statusCode, '2') && 410 !== $statusCode) { // Do NOT include the response content in the error ...
I think you should keep the old exception. There are a lot of places that catch this exception and a few of them count on it. So for the ease of this PR I'd say keep the old one
mbin
github_2023
others
1,095
MbinOrg
melroy89
@@ -0,0 +1,57 @@ +bookmark_front: + controller: App\Controller\BookmarkListController::front + defaults: { sortBy: hot, time: '∞', federation: all } + path: /lists/show/{list}/{sortBy}/{time}/{federation} + methods: [GET] + requirements: &front_requirement + sortBy: "%default_sort_options%" + ...
Let's make it more unique, like what it actually is, before it cause confusing in the future: ```suggestion path: /bookmark-lists ```
mbin
github_2023
others
1,095
MbinOrg
melroy89
@@ -0,0 +1,61 @@ +api_bookmark_front: + controller: App\Controller\Api\Bookmark\BookmarkListApiController::front + path: /api/lists/show
same for the API... ```suggestion path: /api/bookmark-lists/show ```
mbin
github_2023
others
1,095
MbinOrg
melroy89
@@ -0,0 +1,77 @@ +{% extends 'base.html.twig' %} + +{%- block title -%} + {{- 'bookmark_lists'|trans }} - {{ parent() -}} +{%- endblock -%} + +{% block mainClass %}page-bookmark-lists{% endblock %} + +{% block header_nav %} +{% endblock %} + +{% block sidebar_top %} +{% endblock %} + +{% block body %} + <h1 hidde...
Add `alt` text. So people can see what this star icon means.
mbin
github_2023
javascript
1,095
MbinOrg
melroy89
@@ -199,6 +199,34 @@ export default class extends Controller { } } + /** + * Calls the address attached to the nearest link node. Replaces the outer html of the nearest `cssclass` parameter + * with the response from the link + */ + async linkCallback(event) { + const cssClass =...
Remove console log pollution.
mbin
github_2023
others
1,141
MbinOrg
BentiGorlich
@@ -0,0 +1,30 @@ +# Inspired by: https://github.com/dependabot/dependabot-core/blob/main/.github/dependabot.yml +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +u...
I think saturday morning would give us more time to implement the changes. After all we will have more time in general on weekends vs on weekdays
mbin
github_2023
php
1,145
MbinOrg
BentiGorlich
@@ -0,0 +1,30 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */
Should be removed :D
mbin
github_2023
php
1,145
MbinOrg
BentiGorlich
@@ -0,0 +1,30 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20240923164233 extends AbstractMigration +{ + public function...
Where did you get this from? Was it indeed autogenerated by symfony or is it from their docs?
mbin
github_2023
others
1,101
MbinOrg
BentiGorlich
@@ -25,16 +25,15 @@ "doctrine/doctrine-migrations-bundle": "^3.3.1", "doctrine/orm": "^2.19.6", "embed/embed": "^4.4.12", - "endroid/qr-code": "^4.8.5", + "endroid/qr-code": "^5.1.0", "friendsofsymfony/jsrouting-bundle": "^3.5.0", "furqansiddiqui/bip39-mnemonic...
Do we know what this is for?
mbin
github_2023
others
1,101
MbinOrg
BentiGorlich
@@ -328,9 +325,6 @@ "phpdocumentor/type-resolver": { "version": "1.4.0" }, - "phpseclib/phpseclib": { - "version": "3.0.9" - },
How did this get removed
mbin
github_2023
php
1,134
MbinOrg
BentiGorlich
@@ -337,13 +338,21 @@ private function logRequestException(?ResponseInterface $response, string $reque } } - $this->logger->error('{type} get fail: {address}, ex: {e}: {msg} - {content}', [ + // Often 400, 404 errors just return the full HTML page, so we don't want to log the full ...
```suggestion 'content' => substr($content ?? 'No content provided', 0, 200), ``` Otherwise this will throw an exception when `$content` is `null`
mbin
github_2023
others
1,129
MbinOrg
BentiGorlich
@@ -46,11 +46,23 @@ }) }}" data-controller="subject-list" data-action="{{- DYNAMIC_LISTS is same as V_TRUE ? autoAction : manualAction -}}"> - {{ component('entry_comment', { - comment: comment.root ?? comment, - showEntryTitle: false, - showMagazineNam...
What is the `&nbsp;` for?
mbin
github_2023
php
1,122
MbinOrg
melroy89
@@ -284,10 +284,14 @@ public function buildHandle(string $id): string $port = !\is_null(parse_url($id, PHP_URL_PORT)) ? ':'.parse_url($id, PHP_URL_PORT) : ''; + $apObj = $this->apHttpClient->getActorObject($id); + if (!isset($apObj['preferredUsername'])) { + t...
```suggestion throw new \InvalidArgumentException("Webfinger $id does not supply a valid user object"); ```
mbin
github_2023
javascript
1,108
MbinOrg
BentiGorlich
@@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2023-2024 /kbin & Mbin contributors +// +// SPDX-License-Identifier: AGPL-3.0-only + +import { Controller } from '@hotwired/stimulus'; + +/* stimulusFetch: 'lazy' */ +export default class extends Controller { + addSpoiler(event) { + event.preventDefault(); + + ...
```suggestion ::: spoiler spoiler-title ``` I think this would encourage the user to replace this title. I was confused at first as to where the title comes from
mbin
github_2023
javascript
1,108
MbinOrg
BentiGorlich
@@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: 2023-2024 /kbin & Mbin contributors +// +// SPDX-License-Identifier: AGPL-3.0-only + +import { Controller } from '@hotwired/stimulus'; + +/* stimulusFetch: 'lazy' */ +export default class extends Controller { + addSpoiler(event) { + event.preventDefault(); + + ...
```suggestion let spoilerBody = 'spoiler body'; ``` So users know that they should replace this text
mbin
github_2023
javascript
1,111
MbinOrg
BentiGorlich
@@ -106,7 +103,7 @@ export default class extends Controller { return response.json() }) .then(data => { - + // Nothing?
I think you can just leave this blank :D
mbin
github_2023
php
1,098
MbinOrg
melroy89
@@ -57,11 +57,18 @@ public function updateInstance(Instance $instance, bool $force = false): bool $nodeInfoRaw = $this->client->fetchInstanceNodeInfo($linkToUse->href, false); $this->logger->debug('got raw nodeinfo for url {url}: {raw}', ['raw' => $nodeInfoRaw, 'url' => $linkToUse]); - ...
no need to throw up an error?
mbin
github_2023
others
1,080
MbinOrg
BentiGorlich
@@ -101,22 +101,22 @@ {% endblock magazine_ban_notification %} {% block reportlink %} - {% if notification.report.entry is not same as null %} + {% if notification.report.entry is defined and attribute(notification.report, 'entry') is not null %}
Why the attribute call and not just ```suggestion {% if notification.report.entry is defined and notification.report.entry is not same as null %} ```
mbin
github_2023
php
1,066
MbinOrg
melroy89
@@ -168,64 +199,72 @@ private function getActorCacheKey(string $apProfileId): string */ public function getActorObject(string $apProfileId): ?array { - $resp = $this->cache->get( - $this->getActorCacheKey($apProfileId), - function (ItemInterface $item) use ($apProfileId) { -...
Interesting I would though that `TransportExceptionInterface` was extending from Exception, but it isn't in Symfony. Instead TransportExceptionInterface-> ExceptionInterface -> Throwable. I think this is also a bad design pattern by Symfony IMO.
mbin
github_2023
others
1,062
MbinOrg
melroy89
@@ -109,7 +109,7 @@ --kbin-boosted-color: var(--kbin-upvoted-color); // alerts - --kbin-alert-info-bg: rgba(153,116,4,0.15); + --kbin-alert-info-bg: rgba(153,116,4,1);
```suggestion --kbin-alert-info-bg: rgba(153,116,4,0.9); ``` What about 0.9? Still looks good I think. And just ever so slightly transparent.
mbin
github_2023
others
1,055
MbinOrg
melroy89
@@ -3,7 +3,7 @@ <img class="image-preview" src="#"> <button type="button" class="image-preview-clear" data-action="image-upload#clearPreview">x</button> </div> - <div> + <div style="width:300px;">
Inline style is not recommend anymore, try to add a class. And use CSS.
mbin
github_2023
others
1,055
MbinOrg
BentiGorlich
@@ -78,6 +78,10 @@ } } } + + .image-form {
Did you try this on mobile? Setting a width in pixels is often causing problems on mobile...
mbin
github_2023
php
1,053
MbinOrg
melroy89
@@ -87,13 +88,16 @@ public function doWork(MessageInterface $message): void $username = $e->actor->name; } $this->logger->info('Did not create the post, because the magazine {m} restricts posting to mods and {u} is not a mod', ['m' => $e->magazine, 'u' => $username]); + ...
why not a `info`? It's not really an error.. Its more a notification.
mbin
github_2023
php
1,035
MbinOrg
melroy89
@@ -561,6 +561,8 @@ public function updateMagazine(string $actorUrl): ?Magazine $this->handleModeratorCollection($actorUrl, $magazine); } catch (InvalidArgumentException $ignored) { } + } elseif (\is_array($actor['attributedTo'])) {
Causing `undefined array key \"attributedTo\"` in come cases.
mbin
github_2023
php
1,035
MbinOrg
melroy89
@@ -533,7 +533,7 @@ public function updateMagazine(string $actorUrl): ?Magazine $magazine->apInboxUrl = $actor['endpoints']['sharedInbox'] ?? $actor['inbox']; $magazine->apDomain = parse_url($actor['id'], PHP_URL_HOST); $magazine->apFollowersUrl = $actor['followers'] ?? null; - ...
Causing `undefined array key \"attributedTo\"` in come cases.
mbin
github_2023
php
1,039
MbinOrg
melroy89
@@ -63,6 +63,7 @@ public function doWork(MessageInterface $message): void ...$this->activityPubManager->createInboxesFromCC($activity, $entity->user), ...$this->magazineRepository->findAudience($entity->magazine), ]; + $this->logger->debug('sending create activi...
This needed here?
mbin
github_2023
php
1,040
MbinOrg
melroy89
@@ -313,8 +317,11 @@ public function fetchInstanceNodeInfoEndpoints(string $domain, bool $decoded = t $url = "https://$domain/.well-known/nodeinfo"; $resp = $this->cache->get('nodeinfo_endpoints_'.hash('sha256', $url), function (ItemInterface $item) use ($url) { $item->expiresAt(new \Date...
also log the error or? Or log it as a warning..
mbin
github_2023
php
1,013
MbinOrg
BentiGorlich
@@ -367,7 +367,7 @@ public function unsubscribe(User $user): void public function softDelete(): void { - $this->markedForDeletionAt = new \DateTime(); + $this->markedForDeletionAt = date_add(new \DateTime(), new \DateInterval('P30D'));
Functional it is doing the same, but personally I like this better ```suggestion $this->markedForDeletionAt = new \DateTime('now + 30days'); ``` But I let you be the judge :) EDIT: I just noticed that I did it the same way in my code :D
mbin
github_2023
others
981
MbinOrg
BentiGorlich
@@ -41,22 +41,16 @@ On **Debian 12** or later, you can install the latest PHP package repository (th sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' ``` -You can choose between PHP 8.2 or 8.3, but it is recommended to use PHP 8.3. - -Install _PHP 8.2...
```suggestion > If you are upgrading to PHP 8.3 from an older version, please re-review the [PHP configuration]("#php") section of this guide as existing `ini` settings are NOT automatically copied to new versions. Additionally review which php-fpm version is configured in your nginx site ``` The "automatically" is ...
mbin
github_2023
php
985
MbinOrg
melroy89
@@ -419,11 +421,19 @@ public function handleImages(array $attachment): ?Image if (\count($images)) { try { - if ($tempFile = $this->imageManager->download($images[0]['url'])) { + $imageObject = $images[0]; + if (isset($imageObject['height'])) { + ...
Please add code comment explaining why this is done. So in the future it's still understood why.
mbin
github_2023
others
927
MbinOrg
BentiGorlich
@@ -1,5 +1,13 @@ # Ban several AI bots from indexing Mbin instances at all, in order to prevent training their models on users' data. + # Using: https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/blob/master/robots.txt/robots.txt +### Version Information #
```suggestion ### Version Information for nginx-ultimate-bad-bot-blocker # ```
mbin
github_2023
php
830
MbinOrg
melroy89
@@ -0,0 +1,30 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20240626130346 extends AbstractMigration
Do we need 2 separate migration files in this PR? Can't it be 1?
mbin
github_2023
php
830
MbinOrg
melroy89
@@ -40,23 +42,20 @@ public function __construct( public function __invoke(CreateMessage $message): void { $this->object = $message->payload; - $this->logger->debug('Got a CreateMessage of type {t}', [$message->payload['type'], $message->payload]); - + $this->logger->debug('Got a CreateM...
Do you think this is the best way of checking for a private message rather than checking on type `ChatMessage`? 😕
mbin
github_2023
php
830
MbinOrg
melroy89
@@ -95,4 +97,14 @@ private function handlePage(): void } } } + + private function handlePrivateMessage(): void + { + $this->messageManager->createMessage($this->object); + } + + private function handlePrivateMentions(): void + { + // TODO implement private mention...
TODO left?
mbin
github_2023
php
830
MbinOrg
melroy89
@@ -844,6 +844,47 @@ public function extractMarkdownSummary(array $apObject): ?string } } + public function extractMarkdownContent(array $apObject) + { + if (isset($apObject['source']) && isset($apObject['source']['mediaType']) && isset($apObject['source']['content']) && ApObjectExtractor::...
This method is no longer used, correct? If so, it's dead code. Should we remove it??
mbin
github_2023
php
435
MbinOrg
e-five256
@@ -25,6 +25,7 @@ public function getFunctions(): array new TwigFunction('kbin_captcha_enabled', [SettingsExtensionRuntime::class, 'kbinCaptchaEnabled']), new TwigFunction('kbin_mercure_enabled', [SettingsExtensionRuntime::class, 'kbinMercureEnabled']), new TwigFunction('kbin_fede...
very minor, but it doesn't look like this gets used in any twig template (this comment applies to [this function as well](kbinSidebarSectionsLocalOnly)). Now that I look, I don't think `kbinFederatedSearchOnlyLoggedIn()` gets called anywhere either, but that's not something related to your PR. I imagine the overhead on...
mbin
github_2023
others
435
MbinOrg
e-five256
@@ -30,6 +30,7 @@ KBIN_META_DESCRIPTION="content aggregator, content voting, discussion and micro- KBIN_META_KEYWORDS="mbin, content aggregator, open source, fediverse" KBIN_HEADER_LOGO=false KBIN_FEDERATION_PAGE_ENABLED=true +MBIN_SIDEBAR_SECTIONS_LOCAL_ONLY=true
```suggestion MBIN_SIDEBAR_SECTIONS_LOCAL_ONLY=false ``` matching the docker example config, I think we should have this default to all as it seemed like there was more opinions of preferring it all rather than local at time of #141 though if there's strong opinions we could always recheck
mbin
github_2023
others
687
MbinOrg
e-five256
@@ -1,85 +1,94 @@ front: controller: App\Controller\Entry\EntryFrontController::front - defaults: { subscription: home, sortBy: hot, time: '∞', type: all, federation: all, content: threads } - path: /{subscription}/{sortBy}/{time}/{type}/{federation}/{content} + defaults: &front_defaults { subscription: home, co...
I appreciate how you find these things that can be refactored into less copy paste
mbin
github_2023
php
687
MbinOrg
e-five256
@@ -230,22 +230,13 @@ public function resolveTime(?string $value, bool $reverse = false): ?string public function resolveType(?string $value): ?string { - // @todo - $routes = [ - 'all' => 'all', - 'article' => Entry::ENTRY_TYPE_ARTICLE, - 'articles' => Entry::...
same here re: appreciate the refactoring
mbin
github_2023
php
775
MbinOrg
e-five256
@@ -4,7 +4,11 @@ $finder = (new PhpCsFixer\Finder()) ->in(__DIR__) - ->exclude('var') + ->exclude([ + 'var', + 'node_modules', + 'vendor',
Thanks for this, small suggestion ```suggestion 'vendor', 'docker', ``` of adding docker to this too. I could never run it and get ``` /MbinOrg/mbin/docker/storage/postgres): Failed to open directory: Permission denied ``` So I had been running it by specifying the php files I changed i...
mbin
github_2023
php
739
MbinOrg
BentiGorlich
@@ -4,24 +4,25 @@ namespace App\Service\ActivityPub\Webfinger; -use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Request; class WebFingerParameters { public const REL_KEY_NAME = 'rel'; public const HOST_KEY_NAME = 'host'; public const ACCOUNT_KEY_NAME = 'a...
Maybe use `#[ArrayShape(...)]` instead of this return type? Or is that a PHPStorm only thing?
mbin
github_2023
php
694
MbinOrg
e-five256
@@ -13,13 +15,25 @@ class GroupFactory { public function __construct( private readonly UrlGeneratorInterface $urlGenerator, + private readonly MarkdownConverter $markdownConverter, private readonly ContextsProvider $contextProvider, private readonly ImageManager $imageManager ...
my concern here is that this isn't localized, and of course it's difficult to know what language the magazine owner wanted
mbin
github_2023
php
694
MbinOrg
e-five256
@@ -789,4 +794,44 @@ public function getEntityObject(string|array $apObject, array $fullPayload, call return $this->entityManager->getRepository($activity['type'])->find((int) $activity['id']); } + + public function extractMarkdownSummary(array $apObject): ?string + { + if (isset($apObject[...
I just don't think this is a good idea vs parsing it as a regular description like we've been doing, it seems way too prone to failure. For instance a random remote magazine might have a quote in its description like `## “Know the rules well, so you can break them effectively.” - Dalai Lama XIV` we suddenly parse that...
mbin
github_2023
php
694
MbinOrg
e-five256
@@ -441,8 +442,10 @@ public function updateMagazine(string $actorUrl): ?Magazine if (isset($actor['endpoints']['sharedInbox']) || isset($actor['inbox'])) { if (isset($actor['summary'])) { - $converter = new HtmlConverter(['strip_tags' => true]); - $magazine->descrip...
I might be missing it, is `$rules` set here? Not currently seeing where it's being populated from
mbin
github_2023
others
708
MbinOrg
BentiGorlich
@@ -55,8 +55,22 @@ For developers: - [Translations](https://hosted.weblate.org/engage/mbin/) - [Contribution guidelines](CONTRIBUTING.md) - please read first, including before opening an issue! +## Collaborators + +<!-- readme: collaborators -start --> +<!-- readme: collaborators -end --> + +## Contributors + +<!--...
I think this placement is a bit high up in the document. I don't know how it will look like, but I guess it will push everything underneath it way down, to the point where people do not expect there to be anything else. Could you provide a screenshot of how it looks? Or is it not visible until this hits main?
mbin
github_2023
others
642
MbinOrg
BentiGorlich
@@ -21,6 +21,10 @@ {% for flash_error in app.flashes('verify_email_error') %} <div class="alert alert__danger">{{ flash_error }}</div> {% endfor %} + {% if mbin_sso_registrations_enabled() %} + <h4 class="text-muted" style="text-al...
To use the translation system you can change it to ```suggestion <h4 class="text-muted" style="text-align: center; margin:0 !important;">{{ 'register_using_sso'|trans }}</h4> ``` Then you have to create an entry in `messages.en.yml` with the key `register_using_sso`
mbin
github_2023
others
664
MbinOrg
e-five256
@@ -0,0 +1,43 @@ +{ + "env": { + "browser": true, + "node": true, + "es2021": true + }, + "plugins": [ + "@stylistic" + ], + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "ignorePatterns"...
I'm getting ``` Error: ESLint configuration in .eslintrc.json is invalid: - Unexpected top-level property "ignorePatterns". ``` I'm sure it's likely I just didn't configure eslint correctly ``` $ eslint --version v6.4.0 ``` edit: wait latest is `9.0.0`?? I just installed it! I assume it works for ...
mbin
github_2023
others
664
MbinOrg
BentiGorlich
@@ -37,6 +37,15 @@ Install PHP-CS-Fixer first: `composer -d tools install` Then run the following command trying to auto-fix the issues: `./tools/vendor/bin/php-cs-fixer fix` +For JavaScript code inside `assets/` directory, we provided ESLint setup and configuration for linting.
```suggestion For JavaScript code inside the `assets/` directory, we use an ESLint setup and configuration for linting. ```
mbin
github_2023
php
689
MbinOrg
asdfzdfj
@@ -0,0 +1,45 @@ +<?php + +declare(strict_types=1); + +namespace App\Controller; + +use App\Repository\EmbedRepository; +use App\Utils\Embed; +use Psr\Log\LoggerInterface; +use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; +use Symfony\UX\TwigComponent\Attribute\PostMount; + +#[AsTwigComponent('embed', template: ...
this is a twig component though? it should go in `App\Twig\Components` (`src/Twig/Components/EmbedComponent.php`) and unless you somehow also need this to act as a controller it shouldn't extend the `AbstractController` and be named appropiately ```suggestion namespace App\Twig\Components; use App\Repository\Emb...
mbin
github_2023
php
650
MbinOrg
BentiGorlich
@@ -67,16 +67,27 @@ public function __invoke(EntryEmbedMessage $message): void private function fetchCover(Entry $entry, Embed $embed): ?Image { if (!$entry->image) { - $tempFile = null; - if ($embed->image) { - $tempFile = $this->fetchImage($embed->image); - ...
I'd suggest to always write the source url and I am not sure, but I think a `persist` call is needed ```suggestion if ($image) { $image->sourceUrl = $imageUrl; $this->entityManager->persist($image); } ```
mbin
github_2023
php
621
MbinOrg
melroy89
@@ -55,8 +55,10 @@ public function __invoke(LikeMessage $message): void } $actor = $this->activityPubManager->findActorOrCreate($message->payload['actor']); - // Check if actor and entity aren't empty - if (!empty($actor) && !empty($entity)) { + ...
`$activity` is never set? Also `$entity` is fetch above already on line 52.
mbin
github_2023
php
429
MbinOrg
e-five256
@@ -0,0 +1,125 @@ +<?php + +declare(strict_types=1); + +namespace App\Security; + +use App\DTO\UserDto; +use App\Entity\User; +use App\Repository\UserRepository; +use App\Service\IpResolver; +use App\Service\UserManager; +use App\Utils\Slugger; +use Doctrine\ORM\EntityManagerInterface; +use KnpU\OAuth2ClientBundle\Clie...
should this be: ```suggestion $user->oauthZitadelId = $zitadelUser->getId(); ```
mbin
github_2023
php
429
MbinOrg
e-five256
@@ -0,0 +1,125 @@ +<?php + +declare(strict_types=1); + +namespace App\Security; + +use App\DTO\UserDto; +use App\Entity\User; +use App\Repository\UserRepository; +use App\Service\IpResolver; +use App\Service\UserManager; +use App\Utils\Slugger; +use Doctrine\ORM\EntityManagerInterface; +use KnpU\OAuth2ClientBundle\Clie...
I sort of would've expected a composer vendor change for this, but I can't say for sure I know how either keycloak or zitadel work. Keycloak seems to pull in https://github.com/stevenmaguire/oauth2-keycloak/blob/master/src/Provider/KeycloakResourceOwner.php and adds it as a composer dependency
mbin
github_2023
php
429
MbinOrg
asdfzdfj
@@ -0,0 +1,125 @@ +<?php + +declare(strict_types=1); + +namespace App\Security; + +use App\DTO\UserDto; +use App\Entity\User; +use App\Provider\ZitadelResourceOwner; +use App\Repository\UserRepository; +use App\Service\IpResolver; +use App\Service\UserManager; +use App\Utils\Slugger; +use Doctrine\ORM\EntityManagerInte...
shouldn't this be ```suggestion $username = $slugger->slug($zitadelUser->toArray()['preferred_username']); ``` or even better? ```suggestion $username = $slugger->slug($zitadelUser->getPreferredUsername()); ``` --- did a test against a hastily clobbered zitadel instanc...
mbin
github_2023
others
429
MbinOrg
melroy89
@@ -70,6 +70,9 @@ OAUTH_KEYCLOAK_SECRET= OAUTH_KEYCLOAK_URI= OAUTH_KEYCLOAK_REALM= OAUTH_KEYCLOAK_VERSION= +OAUTH_ZITADEL_ID=
does Mbin keeps working without adding this to the config?
mbin
github_2023
php
429
MbinOrg
BentiGorlich
@@ -0,0 +1,163 @@ +<?php + +declare(strict_types=1); + +namespace App\Security; + +use App\DTO\UserDto; +use App\Entity\Image; +use App\Entity\User; +use App\Factory\ImageFactory; +use App\Provider\ZitadelResourceOwner; +use App\Repository\ImageRepository; +use App\Repository\UserRepository; +use App\Service\ImageManag...
Could you refactor this, so that it is not duplicated in 3 authenticators (Zitadel, Google and Facebook)
mbin
github_2023
others
429
MbinOrg
BentiGorlich
@@ -16,4 +16,8 @@ <a href="{{ path('oauth_keycloak_connect') }}" class="btn btn__secondary"><i class="fa-solid fa-lock" aria-hidden="true"></i> Keycloak</a> {% endif %} + {% if this.zitadelEnabled %} + <a href="{{ path('oauth_zitadel_connect') }}" class="btn btn__secondary"><i class...
Could we get the icon of the zitadel org here? If it is too much effort that is fine. Maybe the Zitadel Logo itself (if they have a monochrome svg) would suffice?
mbin
github_2023
others
586
MbinOrg
BentiGorlich
@@ -163,15 +163,16 @@ } }, "scripts": { + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" + },
I don't know what exactly this is doing
mbin
github_2023
others
396
MbinOrg
melroy89
@@ -28,8 +28,12 @@ <include> <directory suffix=".php">src</directory> </include> + <exclude> + <directory suffix=".php">src/DataFixtures</directory> + </exclude> </source> <extensions> + <bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitE...
Keep in mind. I will remove this `extensions` element again in: https://github.com/MbinOrg/mbin/actions/runs/7949978285/job/21701747844 Because we are using PHPUnit 10, which doesn't have support for this `extensions` element anymore.
mbin
github_2023
php
469
MbinOrg
BentiGorlich
@@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20240204141515 extends AbstractMigration +{ + public function...
I am not sure if we should drop the extension here. It doesn't hurt to have it and we don't know if we added it in the upper statement, maybe it already existed
mbin
github_2023
others
492
MbinOrg
BentiGorlich
@@ -129,13 +129,18 @@ Example scrape config: ```yaml scrape_configs: - - job_name: 'mbin-rabbit_queues' + - job_name: "mbin-rabbit_queues" static_configs: - - targets: ['example.org'] - metrics_path: '/metrics/detailed' + - targets: ["example.org"] + metrics_path: "/metrics/detailed" par...
Is this actually working or was it just the auto formatter?