<?php
namespace app\api\controller\user;

use app\Request;
use crmeb\services\UtilService;
use crmeb\utils\Redis;

class UserNotificationController {
    public function snapshot() {
        $uid = 1;
        $redis = Redis::instance();
        // unread
        $unread = Redis::hGet('user:'.$uid, 'unread')??0;
        echo intval($unread);
        // is mining enabled
        $sconf = Redis::hGet('activities', 'mining')??'{"enabled":0}';
        $conf = json_decode($sconf, true);
        print_r($conf);
        // last time mining
        $smymining = Redis::hGet('user:'.$uid, 'mining')??'';
        $mymining = json_decode($smymining, true);
        if ($mymining['progress'] > 0) {
            $mymining = $this->calcMining($mymining);
        }
    }

    protected function calcMining($p) {
        return $p;
    }
}
