Commit 601ee249 authored by jan.koester's avatar jan.koester
Browse files

test

parent 145dec22
Loading
Loading
Loading
Loading
+13 −0
Changes for plugins/contact/contact.cpp: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -185,6 +185,19 @@ namespace blogi {
                dbpp::DBResult res;
                std::vector<char> sbuf;

                // Verification links expire after 24h (see handleVerify), but rows were only
                // ever removed when a link got clicked -- unclicked ones counted toward the
                // limit below forever, locking the address out permanently. Purge them first.
                {
                    auto nowp = std::chrono::system_clock::now();
                    long long cutoff = std::chrono::duration_cast<std::chrono::seconds>(
                        nowp.time_since_epoch()).count() - 86400;
                    sql << "DELETE FROM contact_pending WHERE CAST(created_at AS BIGINT) < "
                        << std::to_string(cutoff).c_str();
                    Args->database[tid]->exec(sql, res);
                    sql.clear();
                }

                sql << "SELECT COUNT(*) FROM contact_pending WHERE mail='"
                    << sql.escaped(sbuf, mail.c_str()) << "'";
                Args->database[tid]->exec(sql, res);