public static function count ($request, $match)
    {
        $userId = $request->user ? $request->user->id : 0;
        $sql = new Pluf_SQL('account_id=%s', array($userId));
        
        $message = new User_Message();
        $res = $message->getList(
                array(
                        'count' => true,
                        'filter' => $sql->gen()
                ));
        // Check permission
        return $res[0]['nb_items'];
    }