Changeset f2c6ab73bbeb02eb513a3952a380305eeeae60ff
- Timestamp:
- 01/27/11 21:22:20 (16 months ago)
- Author:
- ajk <ajk@…>
- Children:
- aab07470af6dc81c6a52e8b8446582745216df17
- Parents:
- cbc895b6da7a6196ef0422747bd7dec2a40551d5
- git-committer:
- ajk <ajk@…> (01/27/11 21:22:20)
- Message:
-
#82: Integrate sub/unsub messages and email confirmation messages
Signed-off-by: ajk <ajk@…>
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r383796f
|
rf2c6ab7
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2010, 2011 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 167 | 167 | mam->insert("group", |
| 168 | 168 | new tlate::group_value(shared_from_this(), u)); |
| 169 | | if (u->is_delivery_email_verified()) |
| 170 | | mam->insert("verified"); |
| 171 | 169 | |
| 172 | 170 | boost::shared_ptr<tlate::tlate> tl = tlate::tlate::parse(tln); |
| … |
… |
|
| 181 | 179 | |
| 182 | 180 | void group::add_subscriber(boost::shared_ptr<user> u, |
| 183 | | server::conn_cb cb) |
| | 181 | server::conn_cb cb, |
| | 182 | boost::asio::ip::address peer) |
| 184 | 183 | { |
| 185 | 184 | BOOST_ASSERT(u); |
| 186 | 185 | ensure_subscriber_role(); |
| 187 | 186 | u->add_role(subscriber_role); |
| 188 | | send_submail(u, "sub.msg", cb); |
| | 187 | if (!u->is_delivery_email_verified()) |
| | 188 | u->send_delivery_email_cookie |
| | 189 | (cb, peer.to_string()); |
| | 190 | else |
| | 191 | send_submail(u, "sub.msg", cb); |
| 189 | 192 | } |
| 190 | 193 | void group::delete_subscriber(boost::shared_ptr<user> u, |
| … |
… |
|
| 193 | 196 | ensure_subscriber_role(); |
| 194 | 197 | u->delete_role(subscriber_role); |
| 195 | | send_submail(u, "unsub.msg", cb); |
| | 198 | if (u->is_delivery_email_verified()) |
| | 199 | send_submail(u, "unsub.msg", cb); |
| 196 | 200 | } |
| 197 | 201 | bool group::is_subscriber(boost::shared_ptr<const user> u) |
-
|
r383796f
|
rf2c6ab7
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2010, 2011 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 99 | 99 | |
| 100 | 100 | void add_subscriber(boost::shared_ptr<user> u, |
| 101 | | server::conn_cb cb); |
| | 101 | server::conn_cb cb, |
| | 102 | boost::asio::ip::address peer); |
| 102 | 103 | void delete_subscriber(boost::shared_ptr<user> u, |
| 103 | 104 | server::conn_cb cb); |
-
|
r2114058
|
rf2c6ab7
|
|
| 83 | 83 | } |
| 84 | 84 | |
| | 85 | bool is_subscriber_role() const |
| | 86 | { return is_subscriber_role(name); } |
| | 87 | |
| | 88 | std::string whose_subscriber_role() const { |
| | 89 | return name.substr(subscriber_prefix.length()); |
| | 90 | } |
| | 91 | |
| 85 | 92 | static bool is_subscriber_role(std::string str) { |
| 86 | 93 | return str.substr(0, subscriber_prefix.length()) |
-
|
r2114058
|
rf2c6ab7
|
|
| 27 | 27 | #include "../tlate/data_model.hh" |
| 28 | 28 | #include "../tlate/tlate.hh" |
| | 29 | #include "../tlate/user_value.hh" |
| 29 | 30 | #include "../uri.hh" |
| 30 | 31 | |
| … |
… |
|
| 152 | 153 | mam->insert("to", |
| 153 | 154 | ::msg::make_phrase(ton) + " <" + to + ">"); |
| 154 | | mam->insert("userid", userid); |
| | 155 | mam->insert("user", new tlate::user_value(shared_from_this())); |
| 155 | 156 | mam->insert("link", link.str()); |
| 156 | 157 | mam->insert("request_ip", request_ip); |
| … |
… |
|
| 166 | 167 | cb.smtpc().send_mail(recv, mos.str()); |
| 167 | 168 | } |
| 168 | | bool user::verify_delivery_email(std::string cookie) |
| | 169 | bool user::verify_delivery_email(std::string cookie, server::conn_cb cb) |
| 169 | 170 | { |
| 170 | 171 | if (delivery_email_verified) return true; |
| … |
… |
|
| 178 | 179 | dbase->add_record(os.str()); |
| 179 | 180 | BOOST_ASSERT(delivery_email_verified); |
| | 181 | |
| | 182 | tlate::data_model::ptr mam(new tlate::data_model); |
| | 183 | |
| | 184 | std::string ton = display_name; |
| | 185 | std::string to = delivery_email; |
| | 186 | std::string from = |
| | 187 | config["alue-name"].as<std::string>() + |
| | 188 | " <" + |
| | 189 | config["operator-email"].as<std::string>() + |
| | 190 | ">"; |
| | 191 | mam->insert("from", from); |
| | 192 | mam->insert("to", |
| | 193 | ::msg::make_phrase(ton) + " <" + to + ">"); |
| | 194 | mam->insert("user", new tlate::user_value(shared_from_this())); |
| | 195 | |
| | 196 | boost::shared_ptr<tlate::tlate> tl = |
| | 197 | tlate::tlate::parse("confirmed.msg"); |
| | 198 | std::ostringstream mos; |
| | 199 | mos << tl->eval(mam); |
| | 200 | |
| | 201 | std::list<std::string> recv; |
| | 202 | recv.push_back(to); |
| | 203 | |
| | 204 | cb.smtpc().send_mail(recv, mos.str()); |
| | 205 | |
| 180 | 206 | return true; |
| 181 | 207 | } |
-
|
r2114058
|
rf2c6ab7
|
|
| 84 | 84 | void send_delivery_email_cookie(server::conn_cb cb, |
| 85 | 85 | std::string request_ip); |
| 86 | | bool verify_delivery_email(std::string cookie); |
| | 86 | bool verify_delivery_email(std::string cookie, |
| | 87 | server::conn_cb cb); |
| 87 | 88 | |
| 88 | 89 | bool allow_cleartext_password() const { |
| … |
… |
|
| 122 | 123 | return err; |
| 123 | 124 | } |
| | 125 | |
| | 126 | boost::shared_ptr<db> get_db() const { return dbase; }; |
| 124 | 127 | }; |
| 125 | 128 | } |
-
|
r2705dcb
|
rf2c6ab7
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2010, 2011 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 77 | 77 | { |
| 78 | 78 | boost::shared_ptr<resource> er; |
| 79 | | if (u->verify_delivery_email(tokstr)) |
| | 79 | if (u->verify_delivery_email(tokstr, cb)) |
| 80 | 80 | er.reset(new redir_resource(cb, |
| 81 | 81 | "/confirmed.html", |
-
|
r383796f
|
rf2c6ab7
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2010, 2011 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 98 | 98 | if (sub) |
| 99 | 99 | { |
| 100 | | gr->add_subscriber(u, cb); |
| 101 | | if (!u->is_delivery_email_verified()) |
| 102 | | u->send_delivery_email_cookie |
| 103 | | (cb, req->get_peer().to_string()); |
| | 100 | gr->add_subscriber(u, cb, req->get_peer()); |
| 104 | 101 | } |
| 105 | 102 | else |
-
|
r868b365
|
rf2c6ab7
|
|
| 1 | 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | 2 | |
| 3 | | Copyright © 2009 Antti-Juhani Kaijanaho |
| | 3 | Copyright © 2009, 2011 Antti-Juhani Kaijanaho |
| 4 | 4 | |
| 5 | 5 | Alue is free software: you can redistribute it and/or modify it |
| … |
… |
|
| 21 | 21 | #include "user_value.hh" |
| 22 | 22 | |
| | 23 | #include "../db/db.hh" |
| | 24 | #include "../db/group.hh" |
| | 25 | #include "../db/role.hh" |
| 23 | 26 | #include "../db/user.hh" |
| 24 | 27 | #include "../html/util.hh" |
| | 28 | #include "../tlate/group_value.hh" |
| | 29 | #include "../tlate/list_value.hh" |
| 25 | 30 | |
| 26 | 31 | namespace tlate |
| … |
… |
|
| 40 | 45 | else if (var == "chpasswd") |
| 41 | 46 | rv.reset(new string_value("/passwd/")); |
| | 47 | else if (var == "subs") |
| | 48 | { |
| | 49 | const std::set<db::role::ptr> &roles = u->get_roles(); |
| | 50 | list_value::ptr sublist; |
| | 51 | for (std::set<db::role::ptr>::const_iterator it |
| | 52 | = roles.begin(); |
| | 53 | it != roles.end(); it++) |
| | 54 | { |
| | 55 | if (!sublist) sublist.reset(new list_value); |
| | 56 | db::role::ptr r = *it; |
| | 57 | if (!r->is_subscriber_role()) continue; |
| | 58 | db::group::ptr gr; |
| | 59 | try |
| | 60 | { |
| | 61 | gr = u->get_db()->lookup_group |
| | 62 | (r->whose_subscriber_role()); |
| | 63 | } |
| | 64 | catch (db::no_such_group) |
| | 65 | { |
| | 66 | continue; |
| | 67 | } |
| | 68 | group_value::ptr gv(new group_value(gr, u)); |
| | 69 | |
| | 70 | sublist->push_back(gv); |
| | 71 | } |
| | 72 | rv = sublist; |
| | 73 | } |
| | 74 | |
| 42 | 75 | return rv; |
| 43 | 76 | } |