You are here

function drupalchat_cron in DrupalChat 8

Same name and namespace in other branches
  1. 6.2 drupalchat.module \drupalchat_cron()
  2. 6 drupalchat.module \drupalchat_cron()
  3. 7.2 drupalchat.module \drupalchat_cron()
  4. 7 drupalchat.module \drupalchat_cron()

Implements hook_cron().

File

./drupalchat.module, line 373
Module code for DrupalChat.

Code

function drupalchat_cron() {
  $drupalchat_log_messages = \Drupal::config('drupalchat.settings')
    ->get('drupalchat_log_messages') ?: 1;
  if ($drupalchat_log_messages != 1) {
    db_delete('drupalchat_msg')
      ->condition('timestamp', time() - 10, '<')
      ->execute();
    db_delete('drupalchat_users')
      ->condition('timestamp', time() - 10, '<')
      ->execute();
  }
  $drupalchat_polling_method = \Drupal::config('drupalchat.settings')
    ->get('drupalchat_polling_method') ?: DRUPALCHAT_AJAX;
  if ($drupalchat_polling_method == DRUPALCHAT_COMMERCIAL) {
    db_delete('drupalchat_users')
      ->condition('timestamp', time() - 60 * 60 * 24 * 14, '<')
      ->execute();
  }
}