Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiration Notice Email Module #63

Open
auspex0 opened this issue Oct 16, 2024 · 1 comment
Open

Expiration Notice Email Module #63

auspex0 opened this issue Oct 16, 2024 · 1 comment

Comments

@auspex0
Copy link

auspex0 commented Oct 16, 2024

Is it possible to create a module that we could load to send an email to the email address registered with a nickname, informing them when their account is due to expire in X days (e.g., 10 days before expiration)? The email would remind them to log in with their nickname and password to prevent the account from expiring.

@auspex0
Copy link
Author

auspex0 commented Oct 20, 2024

i wonder, would something like this work:

/*

  • This file contains code for the NickServ due to expire function.
    */

#include <atheme.h>

static unsigned int ratelimit_count = 0;
static time_t ratelimit_firsttime = 0;

static void send_expiration_email(struct myuser *mu);
static void check_nickname_expiration(void);

void send_expiration_email(struct myuser *mu) {
char *key = random_string(16);

const char *email_content = _("Dear %s,\n\n"
                              "Your nickname \2%s\2 is set to expire in 10 days. "
                              "Please make sure to log in and verify your account to avoid losing your nickname.\n\n"
                              "Thank you,\n"
                              "The Team")
                              % mu->name % entity(mu)->name;

if (!sendemail(NULL, mu, EMAIL_REGISTER, mu->email, key, email_content)) {
    slog(LG_INFO, "Failed to send expiration email to \2%s\2", mu->email);
} else {
    command_success_nodata(NULL, _("An email has been sent to \2%s\2 regarding their nickname expiration."), mu->email);
}

sfree(key);

}

void check_nickname_expiration(void) {
mowgli_node_t *n;
struct myuser *mu;

MOWGLI_ITER_FOREACH(n, myuser_list.head) {
    mu = n->data;

    if (mu->registered + (10 * 86400) > CURRTIME && mu->registered + (11 * 86400) <= CURRTIME) {
        send_expiration_email(mu);
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant