• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python email.group_id_to_email函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: notify

    def notify(self, notification):
        event = notification.event
        group = event.group
        project = group.project
        org = group.organization

        subject = group.get_email_subject()

        link = group.get_absolute_url()

        template = "sentry/emails/error.txt"
        html_template = "sentry/emails/error.html"

        rules = []
        for rule in notification.rules:
            rule_link = reverse("sentry-edit-project-rule", args=[org.slug, project.slug, rule.id])
            rules.append((rule.label, rule_link))

        enhanced_privacy = org.flags.enhanced_privacy

        context = {
            "project_label": project.get_full_name(),
            "group": group,
            "event": event,
            "link": link,
            "rules": rules,
            "enhanced_privacy": enhanced_privacy,
        }

        # if the organization has enabled enhanced privacy controls we dont send
        # data which may show PII or source code
        if not enhanced_privacy:
            interface_list = []
            for interface in event.interfaces.itervalues():
                body = interface.to_email_html(event)
                if not body:
                    continue
                text_body = interface.to_string(event)
                interface_list.append((interface.get_title(), mark_safe(body), text_body))

            context.update({"tags": event.get_tags(), "interfaces": interface_list})

        headers = {
            "X-Sentry-Logger": group.logger,
            "X-Sentry-Logger-Level": group.get_level_display(),
            "X-Sentry-Team": project.team.name,
            "X-Sentry-Project": project.name,
            "X-Sentry-Reply-To": group_id_to_email(group.id),
        }

        self._send_mail(
            subject=subject,
            template=template,
            html_template=html_template,
            project=project,
            reference=group,
            headers=headers,
            context=context,
        )
开发者ID:zenefits,项目名称:sentry,代码行数:59,代码来源:models.py


示例2: notify

    def notify(self, notification):
        event = notification.event
        group = event.group
        project = group.project

        interface_list = []
        for interface in event.interfaces.itervalues():
            body = interface.to_email_html(event)
            if not body:
                continue
            text_body = interface.to_string(event)
            interface_list.append(
                (interface.get_title(), mark_safe(body), text_body)
            )

        subject = group.get_email_subject()

        link = group.get_absolute_url()

        template = 'sentry/emails/error.txt'
        html_template = 'sentry/emails/error.html'

        rules = []
        for rule in notification.rules:
            rule_link = reverse('sentry-edit-project-rule', args=[
                group.organization.slug, project.slug, rule.id
            ])
            rules.append((rule.label, rule_link))

        context = {
            'project_label': project.get_full_name(),
            'group': group,
            'event': event,
            'tags': event.get_tags(),
            'link': link,
            'interfaces': interface_list,
            'rules': rules,
        }

        headers = {
            'X-Sentry-Logger': group.logger,
            'X-Sentry-Logger-Level': group.get_level_display(),
            'X-Sentry-Team': project.team.name,
            'X-Sentry-Project': project.name,
            'X-Sentry-Reply-To': group_id_to_email(group.id),
        }

        self._send_mail(
            subject=subject,
            template=template,
            html_template=html_template,
            project=project,
            group=group,
            headers=headers,
            context=context,
        )
开发者ID:noah-lee,项目名称:sentry,代码行数:56,代码来源:models.py


示例3: notify_users

    def notify_users(self, group, event, fail_silently=False):
        project = group.project

        interface_list = []
        for interface in event.interfaces.itervalues():
            body = interface.to_email_html(event)
            if not body:
                continue
            interface_list.append((interface.get_title(), mark_safe(body)))

        subject = '[%s] %s: %s' % (
            project.name.encode('utf-8'),
            unicode(event.get_level_display()).upper().encode('utf-8'),
            event.error().encode('utf-8').splitlines()[0])

        url_prefix = settings.URL_PREFIX
        parsed = urlparse.urlparse(url_prefix)
        url_prefix = "%s://%s" % (parsed.scheme, parsed.netloc)
        link = '%s%s' % (url_prefix,
            reverse('sentry-group', args=[group.team.slug, group.project.slug, group.id]))

        template = 'sentry/emails/error.txt'
        html_template = 'sentry/emails/error.html'

        context = {
            'group': group,
            'event': event,
            'link': link,
            'interfaces': interface_list,
            'settings_link': self.get_notification_settings_url(),
        }

        headers = {
            'X-Sentry-Logger': event.logger,
            'X-Sentry-Logger-Level': event.get_level_display(),
            'X-Sentry-Project': project.name,
            'X-Sentry-Server': event.server_name,
            'X-Sentry-Reply-To': group_id_to_email(group.pk),
        }

        self._send_mail(
            subject=subject,
            template=template,
            html_template=html_template,
            project=project,
            fail_silently=fail_silently,
            headers=headers,
            context=context,
        )
开发者ID:vls,项目名称:sentry,代码行数:49,代码来源:models.py


示例4: send_notification

    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,代码行数:47,代码来源:activity.py


示例5: get_headers

    def get_headers(self):
        project = self.project
        group = self.group

        headers = {
            'X-Sentry-Team': project.team.slug,
            'X-Sentry-Project': project.slug,
        }

        if group:
            headers.update({
                'X-Sentry-Logger': group.logger,
                'X-Sentry-Logger-Level': group.get_level_display(),
                'X-Sentry-Reply-To': group_id_to_email(group.id),
            })

        return headers
开发者ID:bsergean,项目名称:sentry,代码行数:17,代码来源:base.py


示例6: notify_users

    def notify_users(self, group, event, fail_silently=False):
        project = group.project

        interface_list = []
        for interface in event.interfaces.itervalues():
            body = interface.to_email_html(event)
            if not body:
                continue
            interface_list.append((interface.get_title(), mark_safe(body)))

        subject = '[%s] %s: %s' % (
            project.name.encode('utf-8'),
            unicode(event.get_level_display()).upper().encode('utf-8'),
            event.error().encode('utf-8').splitlines()[0])

        link = group.get_absolute_url()

        template = 'sentry/emails/error.txt'
        html_template = 'sentry/emails/error.html'

        context = {
            'group': group,
            'event': event,
            'tags': event.get_tags(),
            'link': link,
            'interfaces': interface_list,
        }

        headers = {
            'X-Sentry-Logger': event.logger,
            'X-Sentry-Logger-Level': event.get_level_display(),
            'X-Sentry-Project': project.name,
            'X-Sentry-Server': event.server_name,
            'X-Sentry-Reply-To': group_id_to_email(group.pk),
        }

        self._send_mail(
            subject=subject,
            template=template,
            html_template=html_template,
            project=project,
            fail_silently=fail_silently,
            headers=headers,
            context=context,
        )
开发者ID:arty-name,项目名称:sentry,代码行数:45,代码来源:models.py


示例7: setUp

 def setUp(self):
     self.address = ('0.0.0.0', 0)
     self.server = SentrySMTPServer(*self.address)
     self.mailto = group_id_to_email(self.group.pk)
     self.event  # side effect of generating an event
开发者ID:DZTPY,项目名称:sentry,代码行数:5,代码来源:tests.py


示例8: send_notification

    def send_notification(self):
        from sentry.models import Release
        from sentry.utils.email import MessageBuilder, group_id_to_email

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

        send_to = self.get_recipients()

        if not send_to:
            return

        project = self.project
        org = self.project.organization
        group = self.group

        if self.user:
            author = self.user.first_name or self.user.username
        else:
            author = None

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

        if self.group:
            subject = '%s%s' % (subject_prefix, self.group.get_email_subject())
        elif self.type == Activity.RELEASE:
            subject = '%sRelease %s' % (subject_prefix, self.data['version'])
        else:
            raise NotImplementedError

        headers = {}

        context = {
            'data': self.data,
            'author': author,
            'project': project,
            'project_link': absolute_uri(reverse('sentry-stream', kwargs={
                'organization_slug': org.slug,
                'project_id': project.slug,
            })),
        }

        if group:
            group_link = absolute_uri('/{}/{}/group/{}/'.format(org.slug, project.slug, group.id))
            activity_link = '{}activity/'.format(group_link)

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

            context.update({
                'group': group,
                'link': group_link,
                'activity_link': activity_link,
            })

        # TODO(dcramer): abstract each activity email into its own helper class
        if self.type == Activity.RELEASE:
            context.update({
                'release': Release.objects.get(
                    version=self.data['version'],
                    project=project,
                ),
                'release_link': absolute_uri(reverse('sentry-release-details', kwargs={
                    'organization_slug': org.slug,
                    'project_id': project.slug,
                    'version': self.data['version'],
                })),
            })

        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:Natim,项目名称:sentry,代码行数:86,代码来源:activity.py


示例9: notify_about_activity

    def notify_about_activity(self, activity):
        if activity.type not in (Activity.NOTE, Activity.ASSIGNED, Activity.RELEASE):
            return

        candidate_ids = set(self.get_send_to(activity.project))

        # Never send a notification to the user that performed the action.
        candidate_ids.discard(activity.user_id)

        if activity.type == Activity.ASSIGNED:
            # Only notify the assignee, and only if they are in the candidate set.
            recipient_ids = candidate_ids & set(map(int, (activity.data['assignee'],)))
        elif activity.type == Activity.NOTE:
            recipient_ids = candidate_ids - set(
                UserOption.objects.filter(
                    user__in=candidate_ids,
                    key='subscribe_notes',
                    value=u'0',
                ).values_list('user', flat=True)
            )
        else:
            recipient_ids = candidate_ids

        if not recipient_ids:
            return

        project = activity.project
        org = project.organization
        group = activity.group

        headers = {}

        context = {
            'data': activity.data,
            'author': activity.user,
            'project': project,
            'project_link': absolute_uri(reverse('sentry-stream', kwargs={
                'organization_slug': org.slug,
                'project_id': project.slug,
            })),
        }

        if group:
            group_link = absolute_uri('/{}/{}/issues/{}/'.format(
                org.slug, project.slug, group.id
            ))
            activity_link = '{}activity/'.format(group_link)

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

            context.update({
                'group': group,
                'link': group_link,
                'activity_link': activity_link,
            })

        # TODO(dcramer): abstract each activity email into its own helper class
        if activity.type == Activity.RELEASE:
            context.update({
                'release': Release.objects.get(
                    version=activity.data['version'],
                    project=project,
                ),
                'release_link': absolute_uri('/{}/{}/releases/{}/'.format(
                    org.slug,
                    project.slug,
                    activity.data['version'],
                )),
            })

        template_name = activity.get_type_display()

        if group:
            subject = group.get_email_subject()
        elif activity.type == Activity.RELEASE:
            subject = 'Release %s' % activity.data['version']
        else:
            raise NotImplementedError

        self._send_mail(
            project=project,
            send_to=recipient_ids,
            subject=subject,
            context=context,
            template='sentry/emails/activity/{}.txt'.format(template_name),
            html_template='sentry/emails/activity/{}.html'.format(template_name),
            headers=headers,
            reference=activity,
            reply_reference=group,
        )
开发者ID:Andy-hpliu,项目名称:sentry,代码行数:92,代码来源:models.py


示例10: notify

    def notify(self, notification):
        event = notification.event
        group = event.group
        project = group.project
        org = group.organization

        subject = group.get_email_subject()

        link = group.get_absolute_url()

        template = 'sentry/emails/error.txt'
        html_template = 'sentry/emails/error.html'

        rules = []
        for rule in notification.rules:
            rule_link = reverse('sentry-edit-project-rule', args=[
                org.slug, project.slug, rule.id
            ])
            rules.append((rule.label, rule_link))

        enhanced_privacy = org.flags.enhanced_privacy

        context = {
            'project_label': project.get_full_name(),
            'group': group,
            'event': event,
            'link': link,
            'rules': rules,
            'enhanced_privacy': enhanced_privacy,
        }

        # if the organization has enabled enhanced privacy controls we dont send
        # data which may show PII or source code
        if not enhanced_privacy:
            interface_list = []
            for interface in event.interfaces.itervalues():
                body = interface.to_email_html(event)
                if not body:
                    continue
                text_body = interface.to_string(event)
                interface_list.append(
                    (interface.get_title(), mark_safe(body), text_body)
                )

            context.update({
                'tags': event.get_tags(),
                'interfaces': interface_list,
            })

        headers = {
            'X-Sentry-Logger': group.logger,
            'X-Sentry-Logger-Level': group.get_level_display(),
            'X-Sentry-Team': project.team.name,
            'X-Sentry-Project': project.name,
            'X-Sentry-Reply-To': group_id_to_email(group.id),
        }

        for user_id in self.get_send_to(project):
            self.add_unsubscribe_link(context, user_id, project)
            self._send_mail(
                subject=subject,
                template=template,
                html_template=html_template,
                project=project,
                reference=group,
                headers=headers,
                context=context,
                send_to=[user_id],
            )
开发者ID:chanlyi,项目名称:sentry,代码行数:69,代码来源:models.py


示例11: notify_about_activity

    def notify_about_activity(self, activity):
        if activity.type not in (Activity.NOTE, Activity.ASSIGNED, Activity.RELEASE):
            return

        candidate_ids = set(self.get_send_to(activity.project))

        # Never send a notification to the user that performed the action.
        candidate_ids.discard(activity.user_id)

        if activity.type == Activity.ASSIGNED:
            # Only notify the assignee, and only if they are in the candidate set.
            recipient_ids = candidate_ids & set(map(int, (activity.data["assignee"],)))
        elif activity.type == Activity.NOTE:
            recipient_ids = candidate_ids - set(
                UserOption.objects.filter(user__in=candidate_ids, key="subscribe_notes", value=u"0").values_list(
                    "user", flat=True
                )
            )
        else:
            recipient_ids = candidate_ids

        if not recipient_ids:
            return

        project = activity.project
        org = project.organization
        group = activity.group

        headers = {}

        context = {
            "data": activity.data,
            "author": activity.user,
            "project": project,
            "project_link": absolute_uri(
                reverse("sentry-stream", kwargs={"organization_slug": org.slug, "project_id": project.slug})
            ),
        }

        if group:
            group_link = absolute_uri("/{}/{}/issues/{}/".format(org.slug, project.slug, group.id))
            activity_link = "{}activity/".format(group_link)

            headers.update({"X-Sentry-Reply-To": group_id_to_email(group.id)})

            context.update({"group": group, "link": group_link, "activity_link": activity_link})

        # TODO(dcramer): abstract each activity email into its own helper class
        if activity.type == Activity.RELEASE:
            context.update(
                {
                    "release": Release.objects.get(version=activity.data["version"], project=project),
                    "release_link": absolute_uri(
                        "/{}/{}/releases/{}/".format(org.slug, project.slug, activity.data["version"])
                    ),
                }
            )

        template_name = activity.get_type_display()

        if group:
            subject = group.get_email_subject()
        elif activity.type == Activity.RELEASE:
            subject = "Release %s" % activity.data["version"]
        else:
            raise NotImplementedError

        self._send_mail(
            project=project,
            send_to=recipient_ids,
            subject=subject,
            context=context,
            template="sentry/emails/activity/{}.txt".format(template_name),
            html_template="sentry/emails/activity/{}.html".format(template_name),
            headers=headers,
            reference=activity,
            reply_reference=group,
        )
开发者ID:zenefits,项目名称:sentry,代码行数:78,代码来源:models.py


示例12: notify_about_activity

    def notify_about_activity(self, activity):
        if activity.type not in (Activity.NOTE, Activity.ASSIGNED, Activity.RELEASE):
            return

        candidate_ids = set(self.get_send_to(activity.project))

        # Never send a notification to the user that performed the action.
        candidate_ids.discard(activity.user_id)

        if activity.type == Activity.ASSIGNED:
            # Only notify the assignee, and only if they are in the candidate set.
            recipient_ids = candidate_ids & set((activity.data['assignee'],))
        elif activity.type == Activity.NOTE:
            recipient_ids = candidate_ids - set(
                UserOption.objects.filter(
                    user__in=candidate_ids,
                    key='subscribe_notes',
                    value=u'0',
                ).values_list('user', flat=True)
            )
        else:
            recipient_ids = candidate_ids

        if not recipient_ids:
            return

        project = activity.project
        org = project.organization
        group = activity.group

        headers = {}

        context = {
            'data': activity.data,
            'author': activity.user,
            'project': project,
            'project_link': absolute_uri(reverse('sentry-stream', kwargs={
                'organization_slug': org.slug,
                'project_id': project.slug,
            })),
        }

        if group:
            group_link = absolute_uri('/{}/{}/group/{}/'.format(org.slug, project.slug, group.id))
            activity_link = '{}activity/'.format(group_link)

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

            context.update({
                'group': group,
                'link': group_link,
                'activity_link': activity_link,
            })

        # TODO(dcramer): abstract each activity email into its own helper class
        if activity.type == Activity.RELEASE:
            context.update({
                'release': Release.objects.get(
                    version=activity.data['version'],
                    project=project,
                ),
                'release_link': absolute_uri(reverse('sentry-release-details', kwargs={
                    'organization_slug': org.slug,
                    'project_id': project.slug,
                    'version': activity.data['version'],
                })),
            })

        template_name = activity.get_type_display()

        # TODO: Everything below should instead use `_send_mail` for consistency.
        subject_prefix = project.get_option('subject_prefix', settings.EMAIL_SUBJECT_PREFIX)
        if subject_prefix:
            subject_prefix = subject_prefix.rstrip() + ' '

        if group:
            subject = '%s%s' % (subject_prefix, group.get_email_subject())
        elif activity.type == Activity.RELEASE:
            subject = '%sRelease %s' % (subject_prefix, activity.data['version'])
        else:
            raise NotImplementedError

        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=activity,
            reply_reference=group,
        )
        msg.add_users(recipient_ids, project=project)
        msg.send()
开发者ID:paveldedik,项目名称:sentry,代码行数:95,代码来源:models.py


示例13: setUp

 def setUp(self):
     super(TestMailgunInboundWebhookView, self).setUp()
     self.event = self.create_event(event_id='a' * 32)
     self.mailto = group_id_to_email(self.group.pk)
开发者ID:Kayle009,项目名称:sentry,代码行数:4,代码来源:test_mailgun_inbound_webhook.py


示例14: send_notification

    def send_notification(self):
        from sentry.models import User, UserOption
        from sentry.utils.email import MessageBuilder, group_id_to_email

        if self.type != Activity.NOTE or not self.group:
            return

        # TODO(dcramer): some of this logic is duplicated in NotificationPlugin
        # fetch access group members
        user_id_list = set(
            User.objects.filter(
                accessgroup__projects=self.project,
                is_active=True
            ).exclude(
                id=self.user_id,
            ).values_list('id', flat=True)
        )

        if self.project.team:
            # fetch team members
            user_id_list |= set(
                u_id for u_id in self.project.team.member_set.filter(
                    user__is_active=True,
                ).exclude(
                    user__id=self.user_id,
                ).values_list('user', flat=True)
            )

        if not user_id_list:
            return

        disabled = set(UserOption.objects.filter(
            user__in=user_id_list,
            key='subscribe_comments',
            value='0',
        ).values_list('user', flat=True))

        send_to = [
            u_id for u_id in user_id_list if u_id not in disabled
        ]

        if not send_to:
            return

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

        subject = '[%s] %s: %s' % (
            self.project.name,
            author,
            self.data['text'].splitlines()[0][:64])

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

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

        msg = MessageBuilder(
            subject=subject,
            context=context,
            template='sentry/emails/new_note.txt',
            html_template='sentry/emails/new_note.html',
            headers=headers,
        )
        msg.add_users(send_to, project=self.project)

        try:
            msg.send()
        except Exception, e:
            logger = logging.getLogger('sentry.mail.errors')
            logger.exception(e)
开发者ID:beyondtime,项目名称:sentry,代码行数:76,代码来源:activity.py


示例15: send_notification

    def send_notification(self):
        from sentry.models import Release
        from sentry.utils.email import MessageBuilder, group_id_to_email

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

        send_to = self.get_recipients()

        if not send_to:
            return

        project = self.project
        org = self.project.organization

        if self.user:
            author = self.user.first_name or self.user.username
        else:
            author = None

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

        if self.group:
            subject = "%s%s" % (subject_prefix, self.group.get_email_subject())
        elif self.type == Activity.RELEASE:
            subject = "%sRelease %s" % (subject_prefix, self.data["version"])
        else:
            raise NotImplementedError

        headers = {}

        context = {
            "data": self.data,
            "author": author,
            "project": self.project,
            "project_link": absolute_uri(
                reverse("sentry-stream", kwargs={"organization_slug": org.slug, "project_id": project.slug})
            ),
        }

        if self.group:
            headers.update({"X-Sentry-Reply-To": group_id_to_email(self.group.id)})

            context.update({"group": self.group, "link": self.group.get_absolute_url()})

        # TODO(dcramer): abstract each activity email into its own helper class
        if self.type == Activity.RELEASE:
            context.update(
                {
                    "release": Release.objects.get(version=self.data["version"], project=project),
                    "release_link": absolute_uri(
                        reverse(
                            "sentry-release-details",
                            kwargs={
                                "organization_slug": org.slug,
                                "project_id": project.slug,
                                "version": self.data["version"],
                            },
                        )
                    ),
                }
            )

        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:hyserver,项目名称:sentry,代码行数:78,代码来源:activity.py


示例16: send_notification

    def send_notification(self):
        from sentry.models import User, UserOption, ProjectOption
        from sentry.utils.email import MessageBuilder, group_id_to_email

        if self.type != Activity.NOTE or not self.group:
            return

        # TODO(dcramer): some of this logic is duplicated in NotificationPlugin
        # fetch access group members
        user_id_list = set(
            User.objects.filter(
                accessgroup__projects=self.project,
                is_active=True
            ).exclude(
                id=self.user_id,
            ).values_list('id', flat=True)
        )

        if self.project.team:
            # fetch team members
            user_id_list |= set(
                u_id for u_id in self.project.team.member_set.filter(
                    user__is_active=True,
                ).exclude(
                    user__id=self.user_id,
                ).values_list('user', flat=True)
            )

        if not user_id_list:
            return

        disabled = set(UserOption.objects.filter(
            user__in=user_id_list,
            key='subscribe_notes',
            value=u'0',
        ).values_list('user', flat=True))

        send_to = filter(lambda u_id: u_id not in disabled, user_id_list)

        if not send_to:
            return

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

        subject_prefix = ProjectOption.objects.get_value(
            self.project, 'subject_prefix', settings.EMAIL_SUBJECT_PREFIX)
        if subject_prefix:
            subject_prefix = subject_prefix.rstrip() + ' '

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

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

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

        msg = MessageBuilder(
            subject=subject,
            context=context,
            template='sentry/emails/new_note.txt',
            html_template='sentry/emails/new_note.html',
            headers=headers,
            reference=self,
            reply_reference=self.group,
        )
        msg.add_users(send_to, project=self.project)

        try:
            msg.send()
        except Exception as e:
            logger = logging.getLogger('sentry.mail.errors')
            logger.exception(e)
开发者ID:CaseCommonsDevOps,项目名称:sentry,代码行数:78,代码来源:activity.py


示例17: notify

    def notify(self, notification):
        from sentry.models import Commit, Release

        event = notification.event

        environment = event.get_tag('environment')

        group = event.group
        project = group.project
        org = group.organization

        subject = event.get_email_subject()

        link = group.get_absolute_url()

        if environment:
            link = link + '?' + urlencode({'environment': environment})

        template = 'sentry/emails/error.txt'
        html_template = 'sentry/emails/error.html'

        rules = []
        for rule in notification.rules:
            rule_link = '/%s/%s/settings/alerts/rules/%s/' % (org.slug, project.slug, rule.id)

            rules.append((rule.label, rule_link))

        enhanced_privacy = org.flags.enhanced_privacy

        # lets identify possibly suspect commits and owners
        commits = {}
        if features.has('organizations:suggested-commits', org):
            try:
                committers = get_event_file_committers(project, event)
            except (Commit.DoesNotExist, Release.DoesNotExist):
                pass
            except Exception as exc:
                logging.exception(six.text_type(exc))
            else:
                for committer in committers:
                    for commit in committer['commits']:
                        if commit['id'] not in commits:
                            commit_data = commit.copy()
                            commit_data['shortId'] = commit_data['id'][:7]
                            commit_data['author'] = committer['author']
                            commit_data['subject'] = commit_data['message'].split('\n', 1)[0]
                            commits[commit['id']] = commit_data

        context = {
            'project_label': project.get_full_name(),
            'group': group,
            'event': event,
            'link': link,
            'rules': rules,
            'enhanced_privacy': enhanced_privacy,
            'commits': sorted(commits.values(), key=lambda x: x['score'], reverse=True),
            'environment': environment
        }

        # if the organization has enabled enhanced privacy controls we dont send
        # data which may show PII or source code
        if not enhanced_privacy:
            interface_list = []
            for interface in six.itervalues(event.interfaces):
                body = interface.to_email_html(event)
                if not body:
                    continue
                text_body = interface.to_string(event)
                interface_list.append((interface.get_title(), mark_safe(body), text_body))

            context.update({
                'tags': event.get_tags(),
                'interfaces': interface_list,
            })

        headers = {
            'X-Sentry-Logger': group.logger,
            'X-Sentry-Logger-Level': group.get_level_display(),
            'X-Sentry-Project': project.slug,
            'X-Sentry-Reply-To': group_id_to_email(group.id),
        }

        for user_id in self.get_send_to(project=project, event=event):
            self.add_unsubscribe_link(context, user_id, project)
            self._send_mail(
                subject=subject,
                template=template,
                html_template=html_template,
                project=project,
                reference=group,
                headers=headers,
                type='notify.error',
                context=context,
                send_to=[user_id],
            )
开发者ID:alexandrul,项目名称:sentry,代码行数:95,代码来源:models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python email.MessageBuilder类代码示例发布时间:2022-05-27
下一篇:
Python db.is_postgres函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap