from environment import Environment
from flask_mail import Message


class EmailService:

    recipients=["yuvan@storyit.us", "jason@storyit.us", "dhruvit@evincedev.com"] if Environment.USE_TEST_MODE else ["jason@storyit.us", "yuvan@storyit.us", "branson@storyit.us", "wil@storyit.us", "conall@storyit.us"]

    @staticmethod
    def send_manual_verification_alert(mail, username, required_tagged_username, reason="Unknown", ig_is_private="Unknown"):
        subject="New Manual Verification Required"
        sender="storyitinternalalerts"
        
            
        body=f"""
Hey there! A new offer has been pushed to the manual verification dashboard.

Check it out:
https://manualverification-storyit.web.app/

Details:
    Instagram username: @{username}
    Private: {ig_is_private}
    Required tag: @{required_tagged_username}
    Reasoning: {reason}
    
- StoryIt Manual Verification Bot
"""
        msg = Message(subject, sender=sender, recipients=EmailService.recipients)
        msg.body = body
        mail.send(msg)
        print(f"Sent new manual verification alert to {str(EmailService.recipients)}")


    @staticmethod
    def send_manual_verification_reminder(mail, verification_email, verification_username, username, required_tagged_username):
        subject="Reminder: Manual Verification Required"
        sender="storyitinternalalerts"
        recipients=[verification_email]
        body=f"""
Hey again! It's been 5 hours since you requested to follow @{username} using the verification account @{verification_username}. This is a reminder to complete the verification.

Check it out:
https://manualverification-storyit.web.app/

Details:
    Instagram username: @{username}
    Private: True
    Required tag: @{required_tagged_username}
    

- StoryIt Manual Verification Bot
"""
        msg = Message(subject, sender=sender, recipients=recipients)
        msg.body = body
        mail.send(msg)
        print(f"Sent manual verification reminder message to {str(recipients)}")


    @staticmethod
    def send_offer_approved_alert(mail, phone_number, username, content_type, required_tagged_username, ig_is_private, client_name, specific_product, ugc_url, evaluation):
        score = evaluation["score"]
        pros = evaluation["pros"]
        cons = evaluation["cons"]

        subject=f"New Offer Approved for {client_name}"
        sender="storyitinternalalerts" 

        body=f"""
A new offer has been automatically approved for {client_name}!

See the post here: {ugc_url}

Evaluation:
    Score: {score}
    Pros: {pros}
    Cons: {cons}

Details:
    Phone number: {phone_number}
    Instagram username: @{username}
    Private: {ig_is_private}
    Required tag: @{required_tagged_username}
    Content type: {content_type}
    Specific product (in content): {specific_product}
    
- StoryIt Auto-verification

"""
        msg = Message(subject, sender=sender, recipients=EmailService.recipients)
        msg.body = body
        mail.send(msg)
        print(f"Sent new offer approved alert to {str(EmailService.recipients)}")