You are here

public function ContentHubSubscription::updateSharedSecret in Acquia Content Hub 8

Updates the locally stored shared secret.

If the locally stored shared does not match the value stored in the Content Hub, then we need to update it.

File

src/ContentHubSubscription.php, line 266

Class

ContentHubSubscription
Handles operations on the Acquia Content Hub Subscription.

Namespace

Drupal\acquia_contenthub

Code

public function updateSharedSecret() {
  if ($this->clientManager
    ->isConnected()) {
    if ($this
      ->getSharedSecret() !== $this->clientManager
      ->createRequest('getSettings')
      ->getSharedSecret()) {

      // If this condition is met, then the locally stored shared secret is
      // outdated. We need to update the value from the Hub.
      $this
        ->getSettings();
      $message = new FormattableMarkup('The site has been recovered from having a stale shared secret, which prevented webhooks verification.');
      $this->loggerFactory
        ->get('acquia_contenthub')
        ->debug($message);
    }
  }
}