Changeset ec0da3f87768820f9ca9e8065c7998e9d825bd4c
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rd3efc81
|
rec0da3f
|
|
| 39 | 39 | |
| 40 | 40 | boost::shared_ptr<response> markread::operator() |
| 41 | | (boost::shared_ptr<request> req, response::factory) |
| | 41 | (boost::shared_ptr<request> req, response::factory rf) |
| 42 | 42 | { |
| 43 | 43 | db::user::ptr u = req->get_user(); |
| … |
… |
|
| 51 | 51 | |
| 52 | 52 | std::multimap<std::string,std::string> fd = req->get_form_data(); |
| | 53 | std::string ajax = lookup(fd, "ajax"); |
| 53 | 54 | bool value = lookup(fd, "undo") != "yes"; |
| 54 | 55 | std::string msgid = lookup(fd, "msgid"); |
| … |
… |
|
| 63 | 64 | u->unmark_read(msgid); |
| 64 | 65 | } |
| 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 | } |
| 70 | 80 | } |
| 71 | | |
| 72 | 81 | namespace |
| 73 | 82 | { |