Changeset - 5ddd2b163b42
[Not reviewed]
notifyEmail
0 1 0
Dennis Fink - 3 years ago 2022-06-26 11:33:00
dennis.fink@c3l.lu
Remove Purpose.SERVER_AUTH from create_default_context
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
spaceapi/utils.py
Show inline comments
 
@@ -56,49 +56,49 @@ def post_tweet(tweet, spaceapi=None):
 
        api = tweepy.API(auth)
 
        if spaceapi is None:
 
            api.update_status(tweet)
 
        else:
 
            api.update_status(
 
                tweet, lat=spaceapi["location"]["lat"], lon=spaceapi["location"]["lon"]
 
            )
 

	
 

	
 
def post_toot(toot):
 
    if "MASTODON_USERCRED_FILE" in current_app.config:
 
        api = mastodon.Mastodon(
 
            client_id="c3l_spaceapi_clientcred.secret",
 
            access_token=current_app.config["MASTODON_USERCRED_FILE"],
 
            api_base_url="https://chaos.social",
 
        )
 
        api.status_post(toot, visibility="unlisted")
 

	
 

	
 
def post_email(subject, body):
 
    if "EMAIL_PASS" in current_app.config:
 
        smtp_conn = smtplib.SMTP(
 
            current_app.config["EMAIL_HOST"], port=current_app.config["EMAIL_PORT"]
 
        )
 
        ssl_context = ssl.create_default_context(Purpose.SERVER_AUTH)
 
        ssl_context = ssl.create_default_context()
 
        smtp_conn.starttls(ssl_context)
 
        smtp_conn.login(
 
            current_app.config["EMAIL_USER"], current_app.config["EMAIL_PASS"]
 
        )
 
        msg = email.message.EmailMessage(email.policy.SMTP)
 
        msg["To"] = current_app.config["EMAIL_ANNOUNCE_ADDRESS"]
 
        msg["From"] = current_app.config["EMAIL_USER"]
 
        msg["Subject"] = subject
 
        msg.set_content(body)
 
        smtp_conn.send_message(msg)
 

	
 

	
 
class Singleton:
 
    def __new__(cls, *args, **kwargs):
 
        key = str(hash(cls))
 

	
 
        if not hasattr(cls, "_instance_dict"):
 
            cls._instance_dict = {}
 

	
 
        if key not in cls._instance_dict:
 
            cls._instance_dict[key] = super().__new__(cls, *args, **kwargs)
 

	
 
        return cls._instance_dict[key]
 

	
0 comments (0 inline, 0 general)