No notification sent to recipient for first message in a thread

Created on 27 March 2019, over 5 years ago
Updated 10 February 2024, 10 months ago

If a user starts a thread the recipient doesn't get a notification message. Notifications are received for subsequent messages in the thread

In PrivateMessageNotifier the problem starts when checking to see if the recipient has been away long enough to receive the message.
$thread->getLastAccessTimestamp($recipient)

This calls getLastAccessTimestamp in PrivateMessageThread.php. However, if I log the account->id(), it returns the id of then owner/sender of the message. Not the recipient's user id.

  public function getLastAccessTimestamp(AccountInterface $account) {
    \Drupal::logger('PrivateMessageThreadTodd')->notice('In getLASTaccesstimestamp in Private Message Thread the account ID is ' . $account->id() );
    $last_access = $this->getLastAccessTime($account);

    return $last_access ? $last_access->entity->get('access_time')->value : FALSE;
  }

The result is a timestamp that equals the creation timestamp, since they're equal, no notification is sent. To handle this, I've added another if statement just below the $away_time check in the shouldSend function, but I'm sure there's a better way to handle this.

       if ($message->getCreatedTime() == $thread->getLastAccessTimestamp($recipient)) {
          $notify = TRUE;
        }
πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bryantt

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.

Production build 0.71.5 2024