当前位置: 首页>>代码示例>>Python>>正文


Python MessageBuilder.send_async方法代码示例

本文整理汇总了Python中sentry.utils.email.MessageBuilder.send_async方法的典型用法代码示例。如果您正苦于以下问题:Python MessageBuilder.send_async方法的具体用法?Python MessageBuilder.send_async怎么用?Python MessageBuilder.send_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentry.utils.email.MessageBuilder的用法示例。


在下文中一共展示了MessageBuilder.send_async方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_confirm_email_singular

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_confirm_email_singular(self, email, is_new_user=False):
        from sentry import options
        from sentry.utils.email import MessageBuilder

        if not email.hash_is_valid():
            email.set_hash()
            email.save()

        context = {
            'user':
            self,
            'url':
            absolute_uri(
                reverse('sentry-account-confirm-email', args=[self.id, email.validation_hash])
            ),
            'confirm_email':
            email.email,
            'is_new_user':
            is_new_user,
        }
        msg = MessageBuilder(
            subject='%sConfirm Email' % (options.get('mail.subject-prefix'), ),
            template='sentry/emails/confirm_email.txt',
            html_template='sentry/emails/confirm_email.html',
            type='user.confirm_email',
            context=context,
        )
        msg.send_async([email.email])
开发者ID:yogeshmangaj,项目名称:sentry,代码行数:30,代码来源:user.py

示例2: send_sso_unlink_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_sso_unlink_email(self, actor, provider):
        from sentry.utils.email import MessageBuilder
        from sentry.models import LostPasswordHash

        email = self.get_email()

        recover_uri = '{path}?{query}'.format(
            path=reverse('sentry-account-recover'),
            query=urlencode({'email': email}),
        )

        context = {
            'email': email,
            'recover_url': absolute_uri(recover_uri),
            'has_password': self.user.password,
            'organization': self.organization,
            'actor': actor,
            'provider': provider,
        }

        if not self.user.password:
            password_hash = LostPasswordHash.for_user(self.user)
            context['set_password_url'] = password_hash.get_absolute_url(mode='set_password')

        msg = MessageBuilder(
            subject='Action Required for %s' % (self.organization.name, ),
            template='sentry/emails/auth-sso-disabled.txt',
            html_template='sentry/emails/auth-sso-disabled.html',
            type='organization.auth_sso_disabled',
            context=context,
        )
        msg.send_async([email])
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:34,代码来源:organizationmember.py

示例3: send_invite_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_invite_email(self):
        from sentry.utils.email import MessageBuilder

        context = {
            'email': self.email,
            'organization': self.organization,
            'url': absolute_uri(reverse('sentry-accept-invite', kwargs={
                'member_id': self.id,
                'token': self.token,
            })),
        }

        msg = MessageBuilder(
            subject='Join %s in using Sentry' % self.organization.name,
            template='sentry/emails/member-invite.txt',
            html_template='sentry/emails/member-invite.html',
            type='organization.invite',
            context=context,
        )

        try:
            msg.send_async([self.get_email()])
        except Exception as e:
            logger = get_logger(name='sentry.mail')
            logger.exception(e)
开发者ID:WhoTrades,项目名称:sentry,代码行数:27,代码来源:organizationmember.py

示例4: send

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send(self):
        if not self.should_email():
            return

        participants = self.get_participants()
        if not participants:
            return

        activity = self.activity
        project = self.project
        group = self.group

        context = self.get_base_context()
        context.update(self.get_context())

        template = self.get_template()
        html_template = self.get_html_template()
        email_type = self.get_email_type()
        headers = self.get_headers()

        for user, reason in participants.items():
            if group:
                context.update(
                    {
                        'reason':
                        GroupSubscriptionReason.descriptions.get(
                            reason,
                            "are subscribed to this issue",
                        ),
                        'unsubscribe_link':
                        generate_signed_link(
                            user.id,
                            'sentry-account-email-unsubscribe-issue',
                            kwargs={'issue_id': group.id},
                        ),
                    }
                )
            user_context = self.get_user_context(user)
            if user_context:
                user_context.update(context)
            else:
                user_context = context

            msg = MessageBuilder(
                subject=self.get_subject_with_prefix(),
                template=template,
                html_template=html_template,
                headers=headers,
                type=email_type,
                context=user_context,
                reference=activity,
                reply_reference=group,
            )
            msg.add_users([user.id], project=project)
            msg.send_async()
开发者ID:alexandrul,项目名称:sentry,代码行数:57,代码来源:base.py

示例5: _remove_2fa_non_compliant_member

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
def _remove_2fa_non_compliant_member(member, org, actor=None, actor_key=None, ip_address=None):
    user = member.user
    logging_data = {
        'organization_id': org.id,
        'user_id': user.id,
        'member_id': member.id
    }

    try:
        member.email = member.get_email()
        member.user = None
        member.save()
    except (AssertionError, IntegrityError):
        logger.warning(
            'Could not remove 2FA noncompliant user from org',
            extra=logging_data
        )
    else:
        logger.info(
            '2FA noncompliant user removed from org',
            extra=logging_data
        )
        AuditLogEntry.objects.create(
            actor=actor,
            actor_key=actor_key,
            ip_address=ip_address,
            event=AuditLogEntryEvent.MEMBER_PENDING,
            data=member.get_audit_log_data(),
            organization=org,
            target_object=org.id,
            target_user=user,
        )

        # send invite to setup 2fa
        email_context = {
            'url': member.get_invite_link(),
            'organization': org
        }
        subject = u'{} {} Mandatory: Enable Two-Factor Authentication'.format(
            options.get('mail.subject-prefix'),
            org.name.capitalize(),
        )
        message = MessageBuilder(
            subject=subject,
            template='sentry/emails/setup_2fa.txt',
            html_template='sentry/emails/setup_2fa.html',
            type='user.setup_2fa',
            context=email_context,
        )
        message.send_async([member.email])
开发者ID:alexandrul,项目名称:sentry,代码行数:52,代码来源:auth.py

示例6: send_notification

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_notification(self):
        from sentry.utils.email import MessageBuilder, group_id_to_email

        if not self.group_id:
            return

        if self.type not in (Activity.NOTE, Activity.ASSIGNED):
            return

        send_to = self.get_recipients()

        if not send_to:
            return

        author = self.user.first_name or self.user.username

        subject_prefix = self.project.get_option(
            'subject_prefix', settings.EMAIL_SUBJECT_PREFIX)
        if subject_prefix:
            subject_prefix = subject_prefix.rstrip() + ' '

        subject = '%s%s' % (subject_prefix, self.group.get_email_subject())

        context = {
            'data': self.data,
            'author': author,
            'group': self.group,
            'link': self.group.get_absolute_url(),
        }

        headers = {
            'X-Sentry-Reply-To': group_id_to_email(self.group.id),
        }

        template_name = self.get_type_display()

        msg = MessageBuilder(
            subject=subject,
            context=context,
            template='sentry/emails/activity/{}.txt'.format(template_name),
            html_template='sentry/emails/activity/{}.html'.format(template_name),
            headers=headers,
            reference=self,
            reply_reference=self.group,
        )
        msg.add_users(send_to, project=self.project)
        msg.send_async()
开发者ID:KinKir,项目名称:sentry,代码行数:49,代码来源:activity.py

示例7: send_approved_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_approved_email(self):
        from sentry.utils.email import MessageBuilder

        user = self.member.user
        email = user.email
        organization = self.team.organization

        context = {"email": email, "name": user.get_display_name(), "organization": organization, "team": self.team}

        msg = MessageBuilder(
            subject="Sentry Access Request",
            template="sentry/emails/access-approved.txt",
            html_template="sentry/emails/access-approved.html",
            context=context,
        )

        msg.send_async([email])
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:19,代码来源:organizationaccessrequest.py

示例8: send_recover_mail

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_recover_mail(self):
        from sentry.utils.email import MessageBuilder

        context = {
            'user': self.user,
            'domain': urlparse(settings.SENTRY_URL_PREFIX).hostname,
            'url': absolute_uri(reverse(
                'sentry-account-recover-confirm',
                args=[self.user.id, self.hash]
            )),
        }
        msg = MessageBuilder(
            subject='%sPassword Recovery' % (settings.EMAIL_SUBJECT_PREFIX,),
            template='sentry/emails/recover_account.txt',
            context=context,
        )
        msg.send_async([self.user.email])
开发者ID:BlueMoebius,项目名称:sentry,代码行数:19,代码来源:lostpasswordhash.py

示例9: send

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send(self):
        if not self.should_email():
            return

        users = self.get_participants()
        if not users:
            return

        activity = self.activity
        project = self.project
        group = self.group

        context = self.get_base_context()
        context.update(self.get_context())

        subject_prefix = self._get_subject_prefix()

        subject = (u'{}{}'.format(
            subject_prefix,
            self.get_subject(),
        )).encode('utf-8')
        template = self.get_template()
        html_template = self.get_html_template()
        email_type = self.get_email_type()
        headers = self.get_headers()

        for user in users:
            if group:
                context['unsubscribe_link'] = generate_signed_link(
                    user.id,
                    'sentry-account-email-unsubscribe-issue',
                    kwargs={'issue_id': group.id},
                )

            msg = MessageBuilder(
                subject=subject,
                template=template,
                html_template=html_template,
                headers=headers,
                type=email_type,
                context=context,
                reference=activity,
                reply_reference=group,
            )
            msg.add_users([user.id], project=project)
            msg.send_async()
开发者ID:bsergean,项目名称:sentry,代码行数:48,代码来源:base.py

示例10: send_sso_link_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_sso_link_email(self):
        from sentry.utils.email import MessageBuilder

        context = {
            'email': self.email,
            'organization_name': self.organization.name,
            'url': absolute_uri(reverse('sentry-auth-link-identity', kwargs={
                'organization_slug': self.organization.slug,
            })),
        }

        msg = MessageBuilder(
            subject='Action Required for %s' % (self.organization.name,),
            template='sentry/emails/auth-link-identity.txt',
            html_template='sentry/emails/auth-link-identity.html',
            context=context,
        )
        msg.send_async([self.get_email()])
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:20,代码来源:organizationmember.py

示例11: send_recover_mail

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_recover_mail(self):
        from sentry import options
        from sentry.http import get_server_hostname
        from sentry.utils.email import MessageBuilder

        context = {
            'user': self.user,
            'domain': get_server_hostname(),
            'url': self.get_absolute_url(),
        }
        msg = MessageBuilder(
            subject='%sPassword Recovery' % (options.get('mail.subject-prefix'),),
            template='sentry/emails/recover_account.txt',
            html_template='sentry/emails/recover_account.html',
            type='user.password_recovery',
            context=context,
        )
        msg.send_async([self.user.email])
开发者ID:Akashguharoy,项目名称:sentry,代码行数:20,代码来源:lostpasswordhash.py

示例12: send_recover_mail

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_recover_mail(self):
        from sentry import options
        from sentry.http import get_server_hostname
        from sentry.utils.email import MessageBuilder

        context = {
            'user': self.user,
            'domain': get_server_hostname(),
            'url': absolute_uri(reverse(
                'sentry-account-recover-confirm',
                args=[self.user.id, self.hash]
            )),
        }
        msg = MessageBuilder(
            subject='%sPassword Recovery' % (options.get('mail.subject-prefix'),),
            template='sentry/emails/recover_account.txt',
            context=context,
        )
        msg.send_async([self.user.email])
开发者ID:280185386,项目名称:sentry,代码行数:21,代码来源:lostpasswordhash.py

示例13: send_request_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_request_email(self):
        from sentry.models import OrganizationMember
        from sentry.utils.email import MessageBuilder

        user = self.member.user
        email = user.email
        organization = self.team.organization

        context = {
            'email': email,
            'name': user.get_display_name(),
            'organization': organization,
            'team': self.team,
            'url': absolute_uri(reverse('sentry-organization-members', kwargs={
                'organization_slug': organization.slug,
            }) + '?ref=access-requests'),
        }

        msg = MessageBuilder(
            subject='Sentry Access Request',
            template='sentry/emails/request-team-access.txt',
            html_template='sentry/emails/request-team-access.html',
            type='team.access.request',
            context=context,
        )

        global_roles = [
            r.id for r in roles.with_scope('org:write')
            if r.is_global
        ]
        team_roles = [
            r.id for r in roles.with_scope('team:write')
        ]

        # find members which are either team scoped or have access to all teams
        member_list = OrganizationMember.objects.filter(
            Q(role__in=global_roles) |
            Q(teams=self.team, role__in=team_roles),
            organization=self.team.organization,
            user__isnull=False,
        ).select_related('user')

        msg.send_async([m.user.email for m in member_list])
开发者ID:BrunoAsato,项目名称:sentry,代码行数:45,代码来源:organizationaccessrequest.py

示例14: send_sso_link_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_sso_link_email(self, actor, provider):
        from sentry.utils.email import MessageBuilder

        link_args = {'organization_slug': self.organization.slug}

        context = {
            'organization': self.organization,
            'actor': actor,
            'provider': provider,
            'url': absolute_uri(reverse('sentry-auth-organization', kwargs=link_args)),
        }

        msg = MessageBuilder(
            subject='Action Required for %s' % (self.organization.name, ),
            template='sentry/emails/auth-link-identity.txt',
            html_template='sentry/emails/auth-link-identity.html',
            type='organization.auth_link',
            context=context,
        )
        msg.send_async([self.get_email()])
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:22,代码来源:organizationmember.py

示例15: send_invite_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send_async [as 别名]
    def send_invite_email(self):
        from sentry.utils.email import MessageBuilder

        context = {
            'email': self.email,
            'organization': self.organization,
            'url': self.get_invite_link(),
        }

        msg = MessageBuilder(
            subject='Join %s in using Sentry' % self.organization.name,
            template='sentry/emails/member-invite.txt',
            html_template='sentry/emails/member-invite.html',
            type='organization.invite',
            context=context,
        )

        try:
            msg.send_async([self.get_email()])
        except Exception as e:
            logger = get_logger(name='sentry.mail')
            logger.exception(e)
开发者ID:duanshuaimin,项目名称:sentry,代码行数:24,代码来源:organizationmember.py


注:本文中的sentry.utils.email.MessageBuilder.send_async方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。