def build_playlist_job(playlist, shots, params, email, full, remote): """ Build playlist file (concatenate all movie previews). This function is aimed at being runned as a job in a job queue. """ from zou.app import app, mail with app.app_context(): job = build_playlist_movie_file(playlist, shots, params, full, remote) # Just in case, since rq jobs which encounter an error raise an # exception in order to be flagged as failed. if job["status"] == "succeeded": message_text = """ Your playlist %s is available at: https://%s/api/data/playlists/%s/jobs/%s/build/mp4 """ % ( playlist["name"], config.DOMAIN_NAME, playlist["id"], job["id"], ) message = Message( body=message_text, subject="CGWire playlist download", recipients=[email], ) mail.send(message)
def build_playlist_job(playlist, email): """ Build playlist file (concatenate all mnovie previews). This function is aimed at being runned as a job in a job queue. """ from zou.app import app, mail with app.app_context(): job = None try: job = build_playlist_movie_file(playlist) except: if job is not None: end_build_job(playlist, job) raise message_text = """ Your playlist %s is available at: https://%s/api/data/playlists/%s/jobs/%s/build/mp4 """ % ( playlist["name"], config.DOMAIN_NAME, playlist["id"], job["id"], ) message = Message( body=message_text, subject="CGWire playlist download", recipients=[email], ) mail.send(message)
def post(self): args = self.get_arguments() token = uuid.uuid4() try: user = persons_service.get_person_by_email(args["email"]) except PersonNotFoundException: return { "error": True, "message": "Email not listed in database." }, 400 auth_tokens_store.add("reset-%s" % token, args["email"], ttl=3600 * 2) message_text = """Hello %s, You have requested for a password reset. You can connect here to change your password: https://%s/reset-change-password/%s Regards, CGWire Team """ % (user["first_name"], current_app.config["DOMAIN_NAME"], token) if current_app.config["MAIL_DEBUG"]: print(message_text) else: message = Message(body=message_text, subject="CGWire password recovery", recipients=[args["email"]]) mail.send(message) return {"success": "Reset token sent"}
def send_email(subject, body, recipient_email, html=None): """ Send an email with given subject and body to given recipient. """ if html is None: html = body message = Message(body=body, html=html, subject=subject, recipients=[recipient_email]) mail.send(message)
def send_email(subject, body, recipient_email, html=None): """ Send an email with given subject and body to given recipient. """ if html is None: html = body with app.app_context(): mail_default_sender = app.config["MAIL_DEFAULT_SENDER"] message = Message(sender="Kitsu Bot <%s>" % mail_default_sender, body=body, html=html, subject=subject, recipients=[recipient_email]) mail.send(message)
def send_email(subject, body, recipient_email, html=None): """ Send an email with given subject and body to given recipient. """ if html is None: html = body with app.app_context(): message = Message( sender="Kitsu Bot <*****@*****.**>", body=body, html=html, subject=subject, recipients=[recipient_email] ) mail.send(message)
def post(self): """ Ressource to allow a user to change his password when he forgets it. --- description: "It uses a classic scheme: a token is sent by email to the user. Then he can change his password." tags: - Authentification parameters: - in: body name: Email description: The email of the user schema: type: object required: - email properties: email: type: string responses: 200: description: Reset token sent 400: description: Email not listed in database """ args = self.get_arguments() try: user = persons_service.get_person_by_email(args["email"]) except PersonNotFoundException: return ( { "error": True, "message": "Email not listed in database." }, 400, ) token = uuid.uuid4() auth_tokens_store.add("reset-%s" % token, args["email"], ttl=3600 * 2) message_text = """Hello %s, You have requested for a password reset. You can connect here to change your password: %s://%s/reset-change-password/%s Regards, CGWire Team """ % ( user["first_name"], current_app.config["DOMAIN_PROTOCOL"], current_app.config["DOMAIN_NAME"], token, ) if current_app.config["MAIL_DEBUG"]: print(message_text) else: message = Message( body=message_text, subject="CGWire password recovery", recipients=[args["email"]], ) mail.send(message) return {"success": "Reset token sent"}