def email_video_link(talk):
    """Send the presenter a link to their video, asking to confirm."""
    meeting_recordings = common.zoom_request(
        requests.get,
        common.ZOOM_API + f"/meetings/{talk['zoom_meeting_id']}/recordings")
    if not len(meeting_recordings["recording_files"]):
        raise RuntimeError("No recordings found")

    message = RECORDING_AVAILABLE_TEMPLATE.render(
        share_url=meeting_recordings["share_url"],
        **talk,
    )

    response = common.api_query(
        requests.post,
        common.MAILGUN_DOMAIN + "messages",
        data={
            "from": "VSF team <*****@*****.**>",
            "to": f"{talk['speaker_name']} <{talk['email']}>",
            "subject": "Approve your Speakers' Corner recording",
            "text": common.markdown_to_plain(message),
            "html": common.markdown_to_email(message),
        })
    logging.info(
        f"Notified the speaker of {talk['zoom_meeting_id']} about recording.")
    return response
def subscribe_registrants_to_mailinglist(zoom_meeting_id):
    """Add registrants from Zoom to Mailgun mailing list."""
    # Get registrants
    registrants = common.meeting_registrants(zoom_meeting_id)

    if registrants:
        # Filter those who want to sign up for emails
        member_data = dict(members=json.dumps([
            dict(address=i['email'],
                 name="{0} {1}".format(i.get('first_name'),
                                       i.get('last_name', '')))
            for i in registrants if (i.get(
                'May we contact you about future Virtual Science Forum events?',
                '') == "Yes")
        ]))

        api_query(requests.post, MEMBERS_ENDPOINT, data=member_data)

    return
Esempio n. 3
0
def weekly_speakers_corner_update(talks):
    now = datetime.datetime.now(tz=pytz.UTC)
    message = WEEKLY_ANNOUNCEMENT_TEMPLATE.render(
        talks=talks,
        now=now,
        this_week=now + datetime.timedelta(days=7),
        next_week=now + datetime.timedelta(days=14),
    )
    data = {
        "from": "VSF team <*****@*****.**>",
        "to": "*****@*****.**",
        "subject": "Speakers' Corner weekly schedule",
        "text": common.markdown_to_plain(message),
        "html": common.markdown_to_email(message),
    }

    return common.api_query(requests.post,
                            common.MAILGUN_DOMAIN + "messages",
                            data=data)
Esempio n. 4
0
if __name__ == "__main__":
    yaml = YAML()
    repo = common.vsf_repo()
    issue = repo.get_issue(int(os.getenv("ISSUE_NUMBER")))
    data = issue.body.replace('\r', '')
    header, body = data.split('---', maxsplit=1)
    header = yaml.load(header)
    if header["to"] in ("vsf_announce", "speakers_corner"):
        to = header["to"] + "@mail.virtualscienceforum.org"
        body += MAILING_LIST_FOOTER(MAILING_LIST_DESCRIPTIONS[header["to"]])
        response = common.api_query(requests.post,
                                    common.MAILGUN_BASE_URL + "messages",
                                    data={
                                        "from": header["from"],
                                        "to": to,
                                        "subject": header["subject"],
                                        "text": common.markdown_to_plain(body),
                                        "html": common.markdown_to_email(body),
                                    })
    else:
        meeting_id = int(header["to"])
        # We are sending an email to zoom meeting participants
        talks, _ = common.talks_data(repo=repo)
        try:
            talk = next(talk for talk in talks
                        if talk["zoom_meeting_id"] == meeting_id)
        except StopIteration:
            # Not a speakers corner talk, no extra data associated.
            talk = {"zoom_meeting_id": meeting_id}