Automatic notification of update changes

Created on 11 September 2019, over 5 years ago
Updated 11 March 2024, 9 months ago

Maybe with a combination of:

Feature request
Status

Postponed

Version

3.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France Grimreaper France 🇫🇷
    1. +++ b/modules/entity_share_notifier/src/Form/EntityShareSubscriberForm.php
      @@ -0,0 +1,153 @@
      +    $form['basic_auth'] = [
      

      If this is an auth method like in the remote config entity, this shouls use the same mecanism now that authentication is pluggable.

    2. +++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php
      @@ -0,0 +1,228 @@
      +      ->getStorage('channel')
      

      Filter the channels based on the langcode, entity type and bundle before loading the channels if possible to avoid loading hundreds of entities depending on the websites.

    3. +++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php
      @@ -0,0 +1,228 @@
      +      // TODO. Will require to add a new field on channel to store the user to
      

      Or this will require to have an array of channel_id, user_id in the subscriber config entity instead of an array of channel IDS.

    4. +++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php
      @@ -0,0 +1,228 @@
      +      ->loadMultiple();
      

      Possible to add a condition on the channels based on $channels_to_notify? To avoid loading unnecessary entities.

    5. +++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php
      @@ -0,0 +1,228 @@
      +      $http_client = $this->clientFactory->fromOptions([
      

      Should we require that a subscriber should reference a remote to benefit from the authentication system? And so we can use the remote manager service to get the HTTP client.

  • 🇧🇪Belgium beerendlauwers

    I wrote some code a long while ago for the channel filtering. This goes before $channels_to_notify[] = $channel->id();:

          $filters = $channel->get('channel_filters');
    
          $passedFilters = true;
          foreach ($filters as $filter) {
            $directField = $filter['path'];
            if ($entity->hasField($directField)) {
    
              // Only checks first value right now.
              $firstValueFromFilter = trim((string)$filter['value'][0]);
    
              if ($filter['operator'] === '=') {
                $fieldValue = trim($entity->get($directField)->getString());
    
                if ($fieldValue !== $firstValueFromFilter) {
                  $passedFilters = false;
                }
              } elseif ($filter['operator'] === 'CONTAINS') {
                if (!Arrays::any($entity->get($directField)->getValue(), function (
                  $element
                ) use ($firstValueFromFilter) {
                  if (isset($element['value'])) {
                    $fieldValue = $element['value'];
                  }
    
                  return $fieldValue === $firstValueFromFilter;
                })) {
                  $passedFilters = false;
                }
              }
            }
          }
    
          if (!$passedFilters) {
            continue;
          }
    
  • 🇧🇪Belgium beerendlauwers

    For number 5, we could load it from the remote_id:

          $remote_id = $subscriber->get('remote_id');
          $remote_config_id = $subscriber->get('remote_config_id');
          $remote = $this->entityTypeManager->getStorage('remote')->load($remote_id);
    
          if (!($remote instanceof RemoteInterface)) {
              throw new \LogicException("Could not load remote with ID $remote_id");
          }
    
          $http_client = $remote->getHttpClient(true);
    

    This could also be done in the constructor if you feel that's cleaner.

Production build 0.71.5 2024