def run(self): while True: invite = db.next_invite() if not invite: time.sleep(SLEEP_INTERVAL) continue repo_name = invite["repo_name"] github_url = invite["github_url"] inviter = invite["inviter"] username = invite["username"] group = fiesta.FiestaGroup.from_id(fiesta_api, invite["group_id"]) welcome_message = {"subject": "Invitation to %[email protected]" % repo_name, "markdown": """ [%s](%s) invited you to a [Gitlist](https://gitlists.com) for [%s](%s). Gitlists are dead-simple mailing lists for GitHub projects. [Click here]($invite_url) to join the list. If you don't want to join, just ignore this message. Have a great day! """ % (inviter, "http://github.com/" + inviter, repo_name, github_url)} user, cache = github.user_info(username) if user.get("email", None): group.add_member(user["email"], display_name=user.get("name", ""), welcome_message=welcome_message, send_invite=True) if not cache: time.sleep(SLEEP_INTERVAL)
def send_invite(username): user = github.user_info(username) if not user.get("email", None): print "No public email: " + username return first_name, _, _ = (user["name"] or "").partition(" ") if len(first_name) < 2: first_name = username message = """From: Mike Dirolf <*****@*****.**> To: %s Subject: Welcome to Gitlists Content-Type: text/plain Hi %s, Thanks for signing up for Gitlists. Gitlists is a simple way to communicate about your GitHub projects. You can give it a try here: https://gitlists.com We love feedback; this is my personal address so please reply with any questions, feedback, or suggestions. Hope you're having a great day, Mike P.S. Gitlists is also open source. If you want to hack on it: https://github.com/fiesta/gitlists """ % (user["email"], first_name) smtp = smtplib.SMTP(settings.relay_host, settings.relay_port) smtp.sendmail("*****@*****.**", [user["email"]], message) smtp.quit()