Social Post Instagram is an extension module for Social Post that enables automated content publishing to Instagram through the Instagram Graph API, integrated with Drupal's Views Bulk Operations.
Key Features:

Project link

https://www.drupal.org/project/social_post_instagram

Comments

m4th3o created an issue. See original summary.

m4th3o’s picture

Assigned: m4th3o » Unassigned
avpaderno’s picture

Title: [1.0x] [D11]Social Post Instagram » [1.0x] Social Post Instagram
Issue summary: View changes

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.

  • New releases are not necessary for these applications, which could require changes that are not backward-compatible. Not creating new releases avoids any possible issue.
  • Please do not change the branch to review once reviews started, except in the case the used branch needs to be deleted.
  • If you have not done it yet, enable GitLab CI for the project, and fix what reported from the phpcs job. This help to fix most of what reviewers would report.
  • For the time this application is open, only your commits are allowed. No other people, including other maintainers/co-maintainers can make commits.
  • 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; when the application status is changed to Fixed, you will be able to change it and opt it into security advisory coverage.
  • Nobody else will get the permission to opt projects into security advisory policy. If there are other maintainers/co-maintainers who need to get that permission, they need to apply with a different module.
  • 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 project moderator before commenting on newly created applications. Project moderators 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. The configuration used for these tools needs to be the same configuration used by GitLab CI, stored in the GitLab Templates repository.
  • 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.

avpaderno’s picture

Status: Needs review » Needs work

I do not have time for a full review.

The license should be the same license used by Drupal core. The license file used for this project is incomplete.

m4th3o’s picture

Status: Needs work » Needs review

Fixed License

bbu23’s picture

Status: Needs review » Needs work

Adding some things I noticed by taking a very quick look:

- Missing schema for the configuration object provided by the module in config/install.
- New modules, which are compatible with Drupal 10 and higher versions are expected to include type declarations in property definitions, and use property promotion. Update all classes.
- I see some bad line indentation, run your code through PHPCS and fix all errors and warnings. I also recommend adding gitlab-ci for automated checks.
- For a new module that aims to be compatible with Drupal 10 and Drupal 11, I would rather implement hooks as class methods as described in Support for object oriented hook implementations using autowired services.
- I recommend adding tests.
- Implement plugins as PHP Attributes instead of PHP Annotations as described in Attribute-based plugins.

/**
 * Post media to Instagram.
 *
 * @Action(
 *   id = "social_post_instagram_post_media",
 *   label = @Translation("Post to Instagram"),
 *   type = "media"
 * )
 */
vishal.kadam’s picture

1. The project is missing a README.md file that follows the template suggested in README.md template.

2. FILE: social_post_instagram.module

/**
 * @file
 * Contains social_post_instagram.module.
 */

The usual description for a .module file is “Hook implementations for the [module name] module”, where [module name] is the module name given in the .info.yml file.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function social_post_instagram_form_user_form_alter(&$form, FormStateInterface $form_state, $form_id) {

The description for this hook should also say for which form that hook is implemented, either by indicating that with the name of the class that implements the form (namespace included) or the form ID (which is usually indicated by getFormId()).

3. FILE: src/InstagramPostAuthManager.php

  /**
   * The session manager.
   *
   * @var \Symfony\Component\HttpFoundation\Session\Session
   */
  protected $session;

  /**
   * The Facebook client object.
   *
   * @var \League\OAuth2\Client\Provider\Facebook
   */
  protected mixed $client;

  /**
   * The current request.
   *
   * @var \Symfony\Component\HttpFoundation\Request
   */
  protected ?Request $request;

  /**
   * The Social Api network manager.
   *
   * @var \Drupal\social_api\Plugin\NetworkManager
   */
  protected $networkManager;

  /**
   * The Facebook access token.
   *
   * @var \League\OAuth2\Client\Token\AccessToken
   */
  protected $token;

  /**
   * The Facebook page long lived access token.
   *
   * @var string
   */
  protected $longLivedToken;

  /**
   * The post data.
   *
   * @var array
   */
  protected $postData;

  /**
   * The target pageId for posting.
   *
   * @var array
   */
  protected $pageId;

  /**
   * InstagramPostAuthManager constructor.
   *
   * @param \Symfony\Component\HttpFoundation\Session\Session $session
   *   The session manager.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   Used to get the parameter code returned by Facebook.
   * @param \Drupal\social_api\Plugin\NetworkManager $network_manager
   *   The Social API network manager.
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The config factory.
   */
  public function __construct(Session $session, RequestStack $request_stack, NetworkManager $network_manager, ConfigFactoryInterface $configFactory) {
    $this->session = $session;
    $this->request = $request_stack->getCurrentRequest();
    $this->networkManager = $network_manager;
    $this->settings = $configFactory->get('social_post_instagram.settings');
  }

FILE: src/Controller/InstagramPostController.php

  /**
   * The network plugin manager.
   *
   * @var \Drupal\social_api\Plugin\NetworkManager
   */
  private $networkManager;

  /**
   * The Instagram authentication manager.
   *
   * @var \Drupal\social_post_instagram\InstagramPostAuthManager
   */
  private $instagramManager;

  /**
   * Used to access GET parameters.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  private $request;

  /**
   * The Social Auth Data Handler.
   *
   * @var \Drupal\social_post\DataHandler
   */
  private $dataHandler;

  /**
   * The logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  protected $loggerFactory;

  /**
   * The social post user manager.
   *
   * @var \Drupal\social_post\User\UserManager
   */
  protected $userManager;

  /**
   * The Messenger service.
   *
   * @var \Drupal\Core\Messenger\MessengerInterface
   */
  protected $messenger;

  /**
   * InstagramAuthController constructor.
   *
   * @param \Drupal\social_api\Plugin\NetworkManager $network_manager
   *   Used to get an instance of social_auth_instagram network plugin.
   * @param \Drupal\social_post\User\UserManager $user_manager
   *   Manages user login/registration.
   * @param \Drupal\social_post_instagram\InstagramPostAuthManager $instagram_manager
   *   Used to manage authentication methods.
   * @param \Symfony\Component\HttpFoundation\RequestStack $request
   *   Used to access GET parameters.
   * @param \Drupal\social_post\DataHandler $data_handler
   *   The social post data handler.
   * @param \Drupal\social_post\Entity\Controller\SocialPostListBuilder $list_builder
   *   The Social Post entity list builder.
   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
   *   Used for logging errors.
   * @param \Drupal\Core\Messenger\MessengerInterface $messenger
   *   The messenger service.
   * @param \Drupal\Core\Config\ConfigFactory $configFactory
   *   The config factory.
   */
  public function __construct(
    NetworkManager $network_manager,
    UserManager $user_manager,
    InstagramPostAuthManager $instagram_manager,
    RequestStack $request,
    DataHandler $data_handler,
    SocialPostListBuilder $list_builder,
    LoggerChannelFactoryInterface $logger_factory,
    MessengerInterface $messenger,
    ConfigFactory $configFactory,
  ) {

    $this->networkManager = $network_manager;
    $this->userManager = $user_manager;
    $this->instagramManager = $instagram_manager;
    $this->request = $request;
    $this->dataHandler = $data_handler;
    $this->listBuilder = $list_builder;
    $this->loggerFactory = $logger_factory;
    $this->messenger = $messenger;

    $this->userManager->setPluginId('social_post_instagram');

    // Sets session prefix for data handler.
    $this->dataHandler->getSessionPrefix('social_post_instagram');
  }

FILE: src/Plugin/Action/PostToInstagram.php

  /**
   * The Instagram API service.
   *
   * @var \Drupal\social_post_instagram\Services\InstagramApiService
   */
  protected $instagramApiService;

  /**
   * The logger factory.
   *
   * @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
   */
  protected $loggerFactory;

  /**
   * Constructs a PostToInstagram object.
   */
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;

  public function __construct(
    array $configuration,
          $plugin_id,
          $plugin_definition,
    InstagramApiService $instagram_api_service,
    LoggerChannelFactoryInterface $logger_factory,
    EntityTypeManagerInterface $entity_type_manager
  ) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->instagramApiService = $instagram_api_service;
    $this->loggerFactory = $logger_factory;
    $this->entityTypeManager = $entity_type_manager;
  }

FILE: src/Services/InstagramApiService.php

    /**
     * Instagram Graph API URL
     */
    protected const INSTAGRAM_API_URL = 'https://graph.facebook.com/';

    /**
     * @var \GuzzleHttp\ClientInterface
     */
    protected $httpClient;

    /**
     * @var \Drupal\Core\Config\ConfigFactoryInterface
     */
    protected $configFactory;

    /**
     * @var \Drupal\Core\Messenger\MessengerInterface
     */
    protected $messenger;

    /**
     * @var \Drupal\Core\Session\AccountProxyInterface
     */
    protected $account;

    /**
     * The file URL generator service.
     *
     * @var \Drupal\Core\File\FileUrlGeneratorInterface
     */
    protected $fileUrlGenerator;

    /**
     * API version.
     *
     * @var string
     */
    protected $apiVersion = 'v24.0';

    /**
     * Constructor.
     *
     * @param \GuzzleHttp\ClientInterface $http_client
     *   The HTTP client.
     * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
     *   The config factory.
     * @param \Drupal\Core\Messenger\MessengerInterface $messenger
     *   The messenger service.
     * @param \Drupal\Core\Session\AccountProxyInterface $account
     *   The current user account.
     * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
     *   The file URL generator service.
     */
    public function __construct(
        ClientInterface $http_client,
        ConfigFactoryInterface $config_factory,
        MessengerInterface $messenger,
        AccountProxyInterface $account,
        FileUrlGeneratorInterface $file_url_generator
    ) {
        $this->httpClient = $http_client;
        $this->configFactory = $config_factory;
        $this->messenger = $messenger;
        $this->account = $account;
        $this->fileUrlGenerator = $file_url_generator;
    }

FILE: src/Settings/InstagramPostSettings.php

    /**
     * Application ID.
     *
     * @var string
     */
    protected $appId;

    /**
     * Application secret.
     *
     * @var string
     */
    protected $appSecret;

    /**
     * The default graph version.
     *
     * @var string
     */
    protected $graphVersion;

    /**
     * The default access token.
     *
     * @var string
     */
    protected $defaultToken;

    /**
     * The redirect URL for social_auth implementer.
     *
     * @var string
     */
    protected $oauthRedirectUrl;

    /**
     * The key repository service.
     *
     * @var \Drupal\key\KeyRepositoryInterface
     */
    protected KeyRepositoryInterface $keyRepository;

    /**
     * Constructor.
     *
     * @param \Drupal\Core\Config\ImmutableConfig $config
     *   The configuration object.
     * @param \Drupal\key\KeyRepositoryInterface $key_repository
     *   The key repository service.
     */
    public function __construct(ImmutableConfig $config, KeyRepositoryInterface $key_repository) {
        parent::__construct($config);
        $this->keyRepository = $key_repository;
    }

New modules, which are compatible with Drupal 10 and higher versions are expected to include type declarations in property definitions, and use constructor property promotion.

4. FILE: src/Form/InstagramPostSettingsForm.php

With Drupal 10 and Drupal 11, there is no longer need to use #default_value for each form element, when the parent class is ConfigFormBase: It is sufficient to use #config_target, as in the following code.

    $form['image_toolkit'] = [
      '#type' => 'radios',
      '#title' => $this->t('Select an image processing toolkit'),
      '#config_target' => 'system.image:toolkit',
      '#options' => [],
    ];

Using that code, it is no longer needed to save the configuration values in the form submission handler: The parent class will take care of that.
For this change, it is necessary to require at least Drupal 10.3, but that is not an issue, since Drupal 10.2.x is no longer supported.

m4th3o’s picture

Status: Needs work » Closed (won't fix)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.