[1.x] Sender.net Integration

Created on 9 February 2024, 5 months ago
Updated 9 May 2024, about 2 months ago

This module facilitates the integration of Drupal with the sender.net service, allowing users to seamlessly connect their Drupal instance with sender.net for enhanced email subscription and management.

Project link

https://www.drupal.org/project/sender_net →

📌 Task
Status

Needs work

Component

module

Created by

🇮🇳India vinaygawade Sawantwadi, Maharashtra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @vinaygawade
  • 🇮🇳India vishal.kadam Mumbai

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review → gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications → , Application workflow → , What to cover in an application review → , and Tools to use for reviews → .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool → only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues → .

  • Status changed to Needs work 4 months ago
  • 🇮🇳India vishal.kadam Mumbai

    1. master is a wrong name for a branch, which needs to be deleted. Release branch names always end with the literal .x as described in Release branches.

    2. Fix phpcs issue.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml sender_net/
    
    FILE: sender_net/src/SenderNetApi.php                                                                 
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE                                                                                                        
    --------------------------------------------------------------------------------
     246 | ERROR | The array declaration extends to column 91 (the limit is 80). The array content should be split up over multiple lines 
    --------------------------------------------------------------------------------

    3. FILE: src/Plugin/Block/SubscriptionBlock.php

      /**
       * Load services.
       *
       * @param array $configuration
       *   The configuration.
       * @param string $plugin_id
       *   The plugin id.
       * @param mixed $plugin_definition
       *   The plugin definition.
       * @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
       *   The form builder.
       */
      public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $formBuilder) {

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

  • Status changed to Needs review 3 months ago
  • 🇮🇳India vinaygawade Sawantwadi, Maharashtra

    Thank you @vishalkadam for addressing the issues. I appreciate your prompt attention to these matters.

    1. The incorrect branch "master" has been deleted, and the appropriate release branch has been created following the convention of ending with ".x".

    2. The phpcs issue regarding the array declaration length has been fixed by splitting the array content over multiple lines, aligning with coding standards and enhancing code readability.

    3. The constructor documentation comment has been adjusted to adhere to the specified format.

    I've made these changes as requested. Could you please review them again to ensure they meet the project's standards? Thank you for your time and cooperation.

  • Status changed to RTBC about 2 months ago
  • 🇮🇳India vishal.kadam Mumbai

    Rest looks fine to me.

    Let’s wait for a Code Review Administrator to take a look and if everything goes fine, you will get the role.

  • Status changed to Needs work about 2 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    • The following points are just a start and don't necessarily encompass all of the changes that may be necessary
    • A specific point may just be an example and may apply in other places
    • A review is about code that doesn't follow the coding standards, contains possible security issue, or does not correctly use the Drupal API; the single points are not ordered, not even by importance

    src/Form/SubscriptionForm.php

         $msg = $this->t("Subscriber with email '@email' already exists.", ['@email' => $email]);
    
          // Subscriber already exists.
          $this->logger->warning($msg);
          $this->messenger()->addError($msg);
    

    The first argument of warning() and similar logger methods is a literal string.

        // Check if subscriber already exists.
        $existingSubscriber = $this->senderApi->getSubscriberByEmail($email);
        if ($existingSubscriber) {
          $msg = $this->t("Subscriber with email '@email' already exists.", ['@email' => $email]);
    
          // Subscriber already exists.
          $this->logger->warning($msg);
          $this->messenger()->addError($msg);
        }
    

    Validating the entered values is a task for validateForm().

      /**
       * Configuration manager.
       *
       * @var \Drupal\Core\Config\ConfigFactoryInterface
       */
      protected $config;
    
      /**
       * Logger channel factory.
       *
       * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
       */
      protected $logger;
    

    Since the parent class is FormBase, those properties are not necessary. Instead, the class should use the methods to set the logger factory and the config factory, or to retrieve a logger and a configuration object.

    src/Form/SettingsForm.php

    **
     * Configure sender.net settings.
     */
    class SettingsForm extends ConfigFormBase implements ContainerInjectionInterface {
    

    ContainerInjectionInterface is already implemented by ConfigFormBase; there is no need to re-implement it.

        $form['api_access_tokens'] = [
          '#type' => 'textarea',
          '#title' => $this->t('Enter your API access token'),
          '#default_value' => $apiKey,
          '#description' => $this->t('Get API access tokens from sender.net <a href="https://app.sender.net/settings/tokens" target="_blank">account</a>.'),
          '#required' => TRUE,
        ];
    
        $form['api_base_url'] = [
          '#type' => 'textfield',
          '#title' => $this->t('Base URL'),
          '#default_value' => 'https://api.sender.net/v2/',
          '#description' => $this->t('Get Base URL from sender.net <a href="https://api.sender.net/#introduction" target="_blank">docs</a>.'),
          '#required' => TRUE,
        ];
    

    URLs should be added to translatable strings via placeholders. Translators are not expected to change the used URL when translating strings.

          catch (\Exception $e) {
            $this->messenger->addError($this->t('Unable to load groups. Please check your API access token and try again.'));
            $this->logger->error('Error loading groups: @error', ['@error' => $e->getMessage()]);
          }
    

    To log exceptions, there is watchdog_exception() or the class method described in that documentation page.

Production build 0.69.0 2024