Changeset 383796fa5544ac0c42f5599e6de3d3aa06cde8bb
- Timestamp:
- 09/26/10 20:55:45 (20 months ago)
- Author:
- Antti-Juhani Kaijanaho <antti-juhani@…>
- Children:
- 4359ba90347589d94f386f25dbdfd36c039000e6
- Parents:
- 11cf105fe323361072281747558cb61752f33fa8
- git-committer:
- Antti-Juhani Kaijanaho <antti-juhani@…> (09/26/10 20:55:45)
- Message:
-
#76: Email subscription and unsubscription notifications
Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r11cf105
|
r383796f
|
|
| 26 | 26 | #include "../msg/entity.hh" |
| 27 | 27 | #include "../msg/multipart.hh" |
| | 28 | #include "../msg/lexutils.hh" |
| 28 | 29 | #include "../msg/text_plain.hh" |
| 29 | 30 | #include "../smtp_client/smtp_client.hh" |
| 30 | 31 | #include "../tlate/data_model.hh" |
| 31 | 32 | #include "../tlate/group_value.hh" |
| | 33 | #include "../tlate/user_value.hh" |
| 32 | 34 | #include "../tlate/tlate.hh" |
| 33 | 35 | |
| … |
… |
|
| 147 | 149 | } |
| 148 | 150 | |
| 149 | | void group::add_subscriber(boost::shared_ptr<user> u) |
| 150 | | { |
| | 151 | void group::send_submail(user::const_ptr u, const char *tln, |
| | 152 | server::conn_cb cb) |
| | 153 | { |
| | 154 | std::string ton = u->get_display_name(); |
| | 155 | std::string to = u->get_delivery_email(); |
| | 156 | std::string from = |
| | 157 | config["alue-name"].as<std::string>() + |
| | 158 | " <" + |
| | 159 | config["operator-email"].as<std::string>() + |
| | 160 | ">"; |
| | 161 | |
| | 162 | tlate::data_model::ptr mam(new tlate::data_model); |
| | 163 | mam->insert("from", from); |
| | 164 | mam->insert("to", |
| | 165 | ::msg::make_phrase(ton) + " <" + to + ">"); |
| | 166 | mam->insert("user", new tlate::user_value(u)); |
| | 167 | mam->insert("group", |
| | 168 | new tlate::group_value(shared_from_this(), u)); |
| | 169 | if (u->is_delivery_email_verified()) |
| | 170 | mam->insert("verified"); |
| | 171 | |
| | 172 | boost::shared_ptr<tlate::tlate> tl = tlate::tlate::parse(tln); |
| | 173 | std::ostringstream mos; |
| | 174 | mos << tl->eval(mam); |
| | 175 | |
| | 176 | std::list<std::string> recv; |
| | 177 | recv.push_back(to); |
| | 178 | |
| | 179 | cb.smtpc().send_mail(recv, mos.str()); |
| | 180 | } |
| | 181 | |
| | 182 | void group::add_subscriber(boost::shared_ptr<user> u, |
| | 183 | server::conn_cb cb) |
| | 184 | { |
| | 185 | BOOST_ASSERT(u); |
| 151 | 186 | ensure_subscriber_role(); |
| 152 | 187 | u->add_role(subscriber_role); |
| 153 | | } |
| 154 | | void group::delete_subscriber(boost::shared_ptr<user> u) |
| | 188 | send_submail(u, "sub.msg", cb); |
| | 189 | } |
| | 190 | void group::delete_subscriber(boost::shared_ptr<user> u, |
| | 191 | server::conn_cb cb) |
| 155 | 192 | { |
| 156 | 193 | ensure_subscriber_role(); |
| 157 | 194 | u->delete_role(subscriber_role); |
| | 195 | send_submail(u, "unsub.msg", cb); |
| 158 | 196 | } |
| 159 | 197 | bool group::is_subscriber(boost::shared_ptr<const user> u) |
-
|
r1a970cd
|
r383796f
|
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | | void add_subscriber(boost::shared_ptr<user> u); |
| 101 | | void delete_subscriber(boost::shared_ptr<user> u); |
| | 100 | void add_subscriber(boost::shared_ptr<user> u, |
| | 101 | server::conn_cb cb); |
| | 102 | void delete_subscriber(boost::shared_ptr<user> u, |
| | 103 | server::conn_cb cb); |
| 102 | 104 | bool is_subscriber(boost::shared_ptr<const user> u); |
| 103 | 105 | private: |
| … |
… |
|
| 121 | 123 | const std::set<boost::shared_ptr<role> > &); |
| 122 | 124 | |
| | 125 | void send_submail(boost::shared_ptr<const user> u, |
| | 126 | const char *tln, |
| | 127 | server::conn_cb cb); |
| | 128 | |
| 123 | 129 | boost::shared_ptr<msg> retrieve(number n) const { |
| 124 | 130 | static boost::shared_ptr<msg> null; |
-
|
r751fac6
|
r383796f
|
|
| 98 | 98 | if (sub) |
| 99 | 99 | { |
| 100 | | gr->add_subscriber(u); |
| | 100 | gr->add_subscriber(u, cb); |
| 101 | 101 | if (!u->is_delivery_email_verified()) |
| 102 | 102 | u->send_delivery_email_cookie |
| … |
… |
|
| 105 | 105 | else |
| 106 | 106 | { |
| 107 | | gr->delete_subscriber(u); |
| | 107 | gr->delete_subscriber(u, cb); |
| 108 | 108 | } |
| 109 | 109 | throw resource_exception(resp); |
-
|
r4c34ee2
|
r383796f
|
|
| 23 | 23 | #include "string_value.hh" |
| 24 | 24 | |
| | 25 | #include "../config.hh" |
| 25 | 26 | #include "../db/group.hh" |
| 26 | 27 | #include "../html/util.hh" |
| … |
… |
|
| 49 | 50 | rv.reset(new sv(boost::lexical_cast<std::string> |
| 50 | 51 | (gr->get_count()))); |
| | 52 | else if (var == "post-address") |
| | 53 | rv.reset(new sv |
| | 54 | (gr->name() + "@" + |
| | 55 | config["canonical-name"].as<std::string>())); |
| 51 | 56 | else if (var == "reading-authorized") |
| 52 | 57 | { |