示例#1
0
    $timeout = Base_NotifyCommon::get_module_setting($module);
    if ($group_similar && count($module_new_notifications) > 1) {
        $message_count++;
        if ($message_count > Base_NotifyCommon::message_refresh_limit) {
            break;
        }
        $notified_cache[$module] = array_keys($module_new_notifications);
        $title = EPESI . ' ' . Base_NotifyCommon::get_module_caption($module);
        $body = __('%d new notifications', array(count($module_new_notifications)));
        $icon = Base_NotifyCommon::get_icon($module);
        $ret[] = array('title' => $title, 'opts' => array('body' => $body, 'icon' => $icon), 'timeout' => $timeout);
    } else {
        foreach ($module_new_notifications as $id => $message) {
            $message_count++;
            if ($message_count > Base_NotifyCommon::message_refresh_limit) {
                break 2;
            }
            $notified_cache[$module][] = $id;
            $title = EPESI . ' ' . Base_NotifyCommon::strip_html($message['title']);
            $body = Base_NotifyCommon::strip_html($message['body']);
            $icon = Base_NotifyCommon::get_icon($module, $message);
            $ret[] = array('title' => $title, 'opts' => array('body' => $body, 'icon' => $icon, 'tag' => $id), 'timeout' => $timeout);
        }
    }
    $all_notified &= count($module_new_notifications) == count($notified_cache[$module]);
}
Base_NotifyCommon::set_notified_cache($notified_cache, $token, $all_notified ? $refresh_time : Base_NotifyCommon::get_last_refresh($token));
if (count($ret)) {
    echo json_encode(array('messages' => $ret));
}
exit;
示例#2
0
 public static function is_refresh_due_telegram($token)
 {
     return time() >= Base_NotifyCommon::get_last_refresh($token) + Base_NotifyCommon::refresh_rate_telegram;
 }