Skip to content
Merged

Dev #159

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
tone_instructions: "chill"
reviews:
profile: "chill"
high_level_summary: true
collapse_walkthrough: true
suggested_labels: false
high_level_summary_in_walkthrough: false
changed_files_summary: false
poem: false
auto_review:
enabled: true
base_branches:
- ".*"
drafts: false
36 changes: 1 addition & 35 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
### Summary

Provide a general description of the code changes in your pull request …
were there any bugs you had fixed? If so, mention them. If these bugs have open
GitHub issues, be sure to tag them here as well, to keep the conversation
linked together.


### Unit test

Are your changes covered with unit tests, and do they not break anything?

You can run the existing unit tests using this command:

vendor/bin/phpunit tests/


### Code style

Have you checked that you code is well-documented and follows the PSR-2 coding
style?

You can check for this using this command:

vendor/bin/phpcs --standard=PSR2 src/ tests/


### Other Information

If there's anything else that's important and relevant to your pull
request, mention that information here. This could include benchmarks,
or other information.

If you are updating any of the CHANGELOG files or are asked to update the
CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.
"@coderabbitai summary"

Thanks for contributing to phpList!
14 changes: 13 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
"role": "Maintainer"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/TatevikGr/rss-bundle.git"
}
],
"support": {
"issues": "https://github.com/phpList/rest-api/issues",
"forum": "https://discuss.phplist.org/",
Expand All @@ -41,7 +47,8 @@
"symfony/test-pack": "^1.0",
"symfony/process": "^6.4",
"zircote/swagger-php": "^4.11",
"ext-dom": "*"
"ext-dom": "*",
"tatevikgr/rss-feed": "dev-main as 0.1.0"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
Expand Down Expand Up @@ -123,5 +130,10 @@
}
}
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
10 changes: 7 additions & 3 deletions config/services/managers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ services:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\MessageManager:
PhpList\Core\Domain\Messaging\Service\Manager\MessageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\TemplateManager:
PhpList\Core\Domain\Messaging\Service\Manager\TemplateManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\TemplateImageManager:
PhpList\Core\Domain\Messaging\Service\Manager\TemplateImageManager:
autowire: true
autoconfigure: true

PhpList\Core\Domain\Messaging\Service\Manager\BounceRegexManager:
autowire: true
autoconfigure: true

Expand Down
5 changes: 5 additions & 0 deletions config/services/messenger_handlers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
PhpList\Core\Domain\Messaging\MessageHandler\CampaignProcessorMessageHandler:
autowire: true
autoconfigure: true
public: false
12 changes: 12 additions & 0 deletions config/services/normalizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,15 @@ services:
PhpList\RestBundle\Statistics\Serializer\TopLocalPartsNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true

PhpList\RestBundle\Subscription\Serializer\UserBlacklistNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true

PhpList\RestBundle\Subscription\Serializer\SubscribePageNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true

PhpList\RestBundle\Messaging\Serializer\BounceRegexNormalizer:
tags: [ 'serializer.normalizer' ]
autowire: true
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\AdminAttributeDefinition;
use PhpList\Core\Domain\Identity\Service\AdminAttributeDefinitionManager;
Expand Down Expand Up @@ -32,7 +33,8 @@ public function __construct(
RequestValidator $validator,
AdminAttributeDefinitionManager $definitionManager,
AdminAttributeDefinitionNormalizer $normalizer,
PaginatedDataProvider $paginatedDataProvider
PaginatedDataProvider $paginatedDataProvider,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);
$this->definitionManager = $definitionManager;
Expand Down Expand Up @@ -89,6 +91,8 @@ public function create(Request $request): JsonResponse
$definitionRequest = $this->validator->validate($request, CreateAttributeDefinitionRequest::class);

$attributeDefinition = $this->definitionManager->create($definitionRequest->getDto());
$this->entityManager->flush();

$json = $this->normalizer->normalize($attributeDefinition, 'json');

return $this->json($json, Response::HTTP_CREATED);
Expand Down Expand Up @@ -156,6 +160,7 @@ public function update(
attributeDefinition: $attributeDefinition,
attributeDefinitionDto: $definitionRequest->getDto(),
);
$this->entityManager->flush();
$json = $this->normalizer->normalize($attributeDefinition, 'json');

return $this->json($json, Response::HTTP_OK);
Expand Down Expand Up @@ -211,6 +216,7 @@ public function delete(
}

$this->definitionManager->delete($attributeDefinition);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down
9 changes: 8 additions & 1 deletion src/Identity/Controller/AdminAttributeValueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\Filter\AdminAttributeValueFilter;
use PhpList\Core\Domain\Identity\Model\Administrator;
Expand All @@ -27,18 +28,21 @@ class AdminAttributeValueController extends BaseController
private AdminAttributeManager $attributeManager;
private AdminAttributeValueNormalizer $normalizer;
private PaginatedDataProvider $paginatedDataProvider;
private EntityManagerInterface $entityManager;

public function __construct(
Authentication $authentication,
RequestValidator $validator,
AdminAttributeManager $attributeManager,
AdminAttributeValueNormalizer $normalizer,
PaginatedDataProvider $paginatedDataProvider
PaginatedDataProvider $paginatedDataProvider,
EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);
$this->attributeManager = $attributeManager;
$this->normalizer = $normalizer;
$this->paginatedDataProvider = $paginatedDataProvider;
$this->entityManager = $entityManager;
}

#[Route(
Expand Down Expand Up @@ -122,6 +126,7 @@ public function createOrUpdate(
definition: $definition,
value: $request->toArray()['value'] ?? null
);
$this->entityManager->flush();
$json = $this->normalizer->normalize($attributeDefinition, 'json');

return $this->json($json, Response::HTTP_CREATED);
Expand Down Expand Up @@ -193,6 +198,7 @@ public function delete(
throw $this->createNotFoundException('Administrator attribute not found.');
}
$this->attributeManager->delete($attribute);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down Expand Up @@ -350,6 +356,7 @@ public function getAttributeDefinition(
attributeDefinitionId: $definition->getId()
);
$this->attributeManager->delete($attribute);
$this->entityManager->flush();

return $this->json(
$this->normalizer->normalize($attribute),
Expand Down
7 changes: 6 additions & 1 deletion src/Identity/Controller/AdministratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\Administrator;
use PhpList\Core\Domain\Identity\Service\AdministratorManager;
Expand Down Expand Up @@ -35,7 +36,8 @@ public function __construct(
RequestValidator $validator,
AdministratorManager $administratorManager,
AdministratorNormalizer $normalizer,
PaginatedDataProvider $paginatedProvider
PaginatedDataProvider $paginatedProvider,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);
$this->administratorManager = $administratorManager;
Expand Down Expand Up @@ -149,6 +151,7 @@ public function createAdministrator(
$createRequest = $validator->validate($request, CreateAdministratorRequest::class);

$administrator = $this->administratorManager->createAdministrator($createRequest->getDto());
$this->entityManager->flush();
$json = $normalizer->normalize($administrator, 'json');

return $this->json($json, Response::HTTP_CREATED);
Expand Down Expand Up @@ -255,6 +258,7 @@ public function updateAdministrator(
/** @var UpdateAdministratorRequest $updateRequest */
$updateRequest = $this->validator->validate($request, UpdateAdministratorRequest::class);
$this->administratorManager->updateAdministrator($administrator, $updateRequest->getDto());
$this->entityManager->flush();

return $this->json($this->normalizer->normalize($administrator), Response::HTTP_OK);
}
Expand Down Expand Up @@ -303,6 +307,7 @@ public function deleteAdministrator(
throw $this->createNotFoundException('Administrator not found.');
}
$this->administratorManager->deleteAdministrator($administrator);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Identity/Controller/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Service\PasswordManager;
use PhpList\Core\Security\Authentication;
Expand All @@ -29,6 +30,7 @@ public function __construct(
Authentication $authentication,
RequestValidator $validator,
PasswordManager $passwordManager,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);

Expand Down Expand Up @@ -74,6 +76,7 @@ public function requestPasswordReset(Request $request): JsonResponse
$resetRequest = $this->validator->validate($request, RequestPasswordResetRequest::class);

$this->passwordManager->generatePasswordResetToken($resetRequest->email);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down Expand Up @@ -117,6 +120,7 @@ public function validateToken(Request $request): JsonResponse
$validateRequest = $this->validator->validate($request, ValidateTokenRequest::class);

$administrator = $this->passwordManager->validatePasswordResetToken($validateRequest->token);
$this->entityManager->flush();

return $this->json([ 'valid' => $administrator !== null]);
}
Expand Down Expand Up @@ -169,6 +173,7 @@ public function resetPassword(Request $request): JsonResponse
$resetRequest->token,
$resetRequest->newPassword
);
$this->entityManager->flush();

if ($success) {
return $this->json([ 'message' => 'Password updated successfully']);
Expand Down
4 changes: 4 additions & 0 deletions src/Identity/Controller/SessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PhpList\RestBundle\Identity\Controller;

use Doctrine\ORM\EntityManagerInterface;
use OpenApi\Attributes as OA;
use PhpList\Core\Domain\Identity\Model\AdministratorToken;
use PhpList\Core\Domain\Identity\Service\SessionManager;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function __construct(
Authentication $authentication,
RequestValidator $validator,
SessionManager $sessionManager,
private readonly EntityManagerInterface $entityManager,
) {
parent::__construct($authentication, $validator);

Expand Down Expand Up @@ -96,6 +98,7 @@ public function createSession(
loginName:$createSessionRequest->loginName,
password: $createSessionRequest->password
);
$this->entityManager->flush();

$json = $normalizer->normalize($token, 'json');

Expand Down Expand Up @@ -163,6 +166,7 @@ public function deleteSession(
}

$this->sessionManager->deleteSession($token);
$this->entityManager->flush();

return $this->json(null, Response::HTTP_NO_CONTENT);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Identity/Request/CreateSessionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

class CreateSessionRequest implements RequestInterface
{
#[Assert\NotBlank]
#[Assert\NotBlank(normalizer: 'trim')]
#[Assert\Type(type: 'string')]
public string $loginName;

#[Assert\NotBlank]
#[Assert\NotBlank(normalizer: 'trim')]
#[Assert\Type(type: 'string')]
public string $password;

Expand Down
2 changes: 1 addition & 1 deletion src/Identity/Request/UpdateAttributeDefinitionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class UpdateAttributeDefinitionRequest implements RequestInterface
{
#[Assert\NotBlank]
#[Assert\NotBlank(normalizer: 'trim')]
public string $name;

public ?string $type = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Identity/Request/ValidateTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ValidateTokenRequest implements RequestInterface
{
#[Assert\NotBlank]
#[Assert\NotBlank(normalizer: 'trim')]
#[Assert\Type(type: 'string')]
public string $token;

Expand Down
Loading
Loading