Changeset ec0da3f87768820f9ca9e8065c7998e9d825bd4c

Show
Ignore:
Timestamp:
08/24/10 14:38:15 (18 months ago)
Author:
Antti-Juhani Kaijanaho <ajk@…>
Children:
751fac6b567d675afee10e627efb5cf786ce5c83
Parents:
d3efc818ad12f25b70157a80a98888a3fbaac544
git-committer:
Antti-Juhani Kaijanaho <ajk@…> (08/24/10 14:38:15)
Message:

[http::markread] Add a simple AJAX protocol

Signed-off-by: Antti-Juhani Kaijanaho <ajk@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • http/markread.cc

    rd3efc81 rec0da3f  
    3939 
    4040        boost::shared_ptr<response> markread::operator() 
    41         (boost::shared_ptr<request> req, response::factory) 
     41        (boost::shared_ptr<request> req, response::factory rf) 
    4242        { 
    4343                db::user::ptr u = req->get_user(); 
     
    5151 
    5252                std::multimap<std::string,std::string> fd = req->get_form_data(); 
     53                std::string ajax = lookup(fd, "ajax"); 
    5354                bool value = lookup(fd, "undo") != "yes"; 
    5455                std::string msgid = lookup(fd, "msgid"); 
     
    6364                                u->unmark_read(msgid); 
    6465                } 
    65                 boost::shared_ptr<redir_resource> r 
    66                         (new redir_resource(cb, redir.to_string(), 
    67                                             "303 See other")); 
    68                 throw resource_exception(r); 
    69         } 
     66                if (ajax.empty() || ajax == "no") 
     67                { 
     68                        boost::shared_ptr<redir_resource> r 
     69                                (new redir_resource(cb, redir.to_string(), 
     70                                                    "303 See other")); 
     71                        throw resource_exception(r); 
     72                } 
     73                boost::shared_ptr<response> rv = rf("200 Ok"); 
     74                std::ostream &os = rv->body("text/plain"); 
     75                os << "AJAX " 
     76                   << (u->has_read(msgid) ? "YES" : "NO") 
     77                   << "\r\n"; 
     78                return rv; 
     79        } 
    7080} 
    71  
    7281namespace 
    7382{