Exemplo n.º 1
0
 def notify(self, userInfo, adminInfo):
     subject = 'Welcome to %s' % (self.groupInfo.name)
     text = self.textTemplate(userInfo=userInfo, adminInfo=adminInfo)
     html = self.htmlTemplate(userInfo=userInfo, adminInfo=adminInfo)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html)
     self.request.response.setHeader(b'Content-Type', self.oldContentType)
Exemplo n.º 2
0
 def notify(self, adminInfo):
     s = 'New group: {0}'.format(self.groupInfo.name)
     text = self.textTemplate(adminInfo=adminInfo)
     html = self.htmlTemplate(adminInfo=adminInfo)
     ms = MessageSender(self.context, adminInfo)
     ms.send_message(s, text, html)
     self.request.response.setHeader(b'Content-Type', self.oldContentType)
Exemplo n.º 3
0
 def notify(self, userInfo, adminInfo):
     subject = 'Welcome to %s' % (self.groupInfo.name)
     text = self.textTemplate(userInfo=userInfo, adminInfo=adminInfo)
     html = self.htmlTemplate(userInfo=userInfo, adminInfo=adminInfo)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html)
     self.request.response.setHeader(b'Content-Type', self.oldContentType)
Exemplo n.º 4
0
 def notify(self, userInfo, problemAddress, toAddresses):
     subject = 'Email delivery problems (action required)'
     text = self.textTemplate(userInfo=userInfo, email=problemAddress)
     html = self.htmlTemplate(userInfo=userInfo, email=problemAddress)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html, toAddresses=toAddresses)
     self.request.response.setHeader(to_ascii('Content-Type'),
                                     self.oldContentType)
 def notify(self, userInfo, problemAddress, toAddresses):
     subject = 'Email delivery problems (action required)'
     text = self.textTemplate(userInfo=userInfo, email=problemAddress)
     html = self.htmlTemplate(userInfo=userInfo, email=problemAddress)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html, toAddresses=toAddresses)
     self.request.response.setHeader(to_ascii('Content-Type'),
                                     self.oldContentType)
Exemplo n.º 6
0
 def notify(self, adminInfo):
     s = 'New group: {0}'.format(self.groupInfo.name)
     text = self.textTemplate(adminInfo=adminInfo)
     html = self.htmlTemplate(adminInfo=adminInfo)
     ms = MessageSender(self.context, adminInfo)
     ms.send_message(s, text, html)
     self.request.response.setHeader(b'Content-Type',
                                     self.oldContentType)
Exemplo n.º 7
0
 def notify(self, siteInfo, userInfo, resetLink, toAddr):
     s = 'Password reset at {0} (action required)'
     subject = s.format(siteInfo.name)
     text = self.textTemplate(userInfo=userInfo, resetLink=resetLink)
     html = self.htmlTemplate(userInfo=userInfo, resetLink=resetLink)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html, toAddresses=[toAddr])
     self.request.response.setHeader(to_ascii('Content-Type'),
                                     self.oldContentType)
Exemplo n.º 8
0
 def notify(self, userInfo, emailAddress, verifyLink):
     subject = 'Verify your email address (action required)'.encode(UTF8)
     text = self.textTemplate(userInfo=userInfo,
                              emailAddress=emailAddress,
                              verifyLink=verifyLink)
     html = self.htmlTemplate(userInfo=userInfo,
                              emailAddress=emailAddress,
                              verifyLink=verifyLink)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html, toAddresses=[emailAddress])
     self.request.response.setHeader(b'Content-Type', self.oldContentType)
Exemplo n.º 9
0
 def notify(self, userInfo, emailAddress, verifyLink):
     subject = 'Verify your email address (action required)'.encode(UTF8)
     text = self.textTemplate(userInfo=userInfo,
                              emailAddress=emailAddress,
                              verifyLink=verifyLink)
     html = self.htmlTemplate(userInfo=userInfo,
                              emailAddress=emailAddress,
                              verifyLink=verifyLink)
     ms = MessageSender(self.context, userInfo)
     ms.send_message(subject, text, html, toAddresses=[emailAddress])
     self.request.response.setHeader(b'Content-Type',
                                     self.oldContentType)
Exemplo n.º 10
0
 def test_send_message(self, m_NU, m_A, m_IGUI, m_eU, m_sI):
     m_sI().name = 'Example'
     m_sI().get_support_email.return_value = '*****@*****.**'
     m_eU().get_delivery_addresses.return_value = ['*****@*****.**', ]
     toUserInfo = MagicMock()
     toUserInfo.name = m_IGUI().name = 'Example Person'
     ms = MessageSender(MagicMock(), toUserInfo)
     ms.send_message('Ethel the Frog',
                     'Tonight on Ethel the Frog we look at violence\u2026',
                     '<p>Tonight on Ethel the Frog we look at violence&#8230</p>',
                     '*****@*****.**',
                     ['*****@*****.**', '*****@*****.**', ])
     self.assertEqual(2, m_NU().send_message.call_count)
Exemplo n.º 11
0
 def notify(self, adminInfo, userInfo, groupInfo):
     s = 'Invitation to {0} accepted'
     subject = s.format(groupInfo.name).encode(UTF8)
     text = self.textTemplate(userInfo=userInfo,
                              adminInfo=adminInfo,
                              groupInfo=groupInfo)
     html = self.htmlTemplate(userInfo=userInfo,
                              adminInfo=adminInfo,
                              groupInfo=groupInfo)
     ms = MessageSender(self.context, adminInfo)
     ms.send_message(subject, text, html)
     self.request.response.setHeader(to_ascii('Content-Type'),
                                     self.oldContentType)
Exemplo n.º 12
0
 def test_send_message(self, m_NU, m_A, m_IGUI, m_eU, m_sI):
     m_sI().name = 'Example'
     m_sI().get_support_email.return_value = '*****@*****.**'
     m_eU().get_delivery_addresses.return_value = [
         '*****@*****.**',
     ]
     toUserInfo = MagicMock()
     toUserInfo.name = m_IGUI().name = 'Example Person'
     ms = MessageSender(MagicMock(), toUserInfo)
     ms.send_message(
         'Ethel the Frog',
         'Tonight on Ethel the Frog we look at violence\u2026',
         '<p>Tonight on Ethel the Frog we look at violence&#8230</p>',
         '*****@*****.**', [
             '*****@*****.**',
             '*****@*****.**',
         ])
     self.assertEqual(2, m_NU().send_message.call_count)
Exemplo n.º 13
0
    def send_message(self, fromAddress, adminInfo, message):
        sender = MessageSender(self.context, adminInfo)
        subject = _('request-admin-message-subject',  'Request to join ${groupName}',
                    mapping={'groupName': self.groupInfo.name})
        newRequest = self.request
        newRequest.form['userId'] = self.userInfo.id
        newRequest.form['email'] = fromAddress
        newRequest.form['mesg'] = message
        newRequest.form['adminId'] = adminInfo.id

        txt = getMultiAdapter((self.context, newRequest), name="request_message.txt")()
        html = getMultiAdapter((self.context, newRequest), name="request_message.html")()
        try:
            sender.send_message(subject, txt, html, fromAddress)
        except ValueError:  # No valid email address
            m = 'Cannot send a "Request to join" notification to the administrator %s (%s) for '\
                'the group %s (%s) on %s (%s) because they lack a verified email address. '\
                'Skipping the notification.'
            log.warn(m, adminInfo.name, adminInfo.id, self.groupInfo.name,
                     self.groupInfo.id, self.siteInfo.name, self.siteInfo.id)
        self.request.response.setHeader(b'Content-Type', self.oldContentType)
Exemplo n.º 14
0
    def send_message(self, fromAddress, adminInfo, message):
        sender = MessageSender(self.context, adminInfo)
        subject = _('request-admin-message-subject',
                    'Request to join ${groupName}',
                    mapping={'groupName': self.groupInfo.name})
        newRequest = self.request
        newRequest.form['userId'] = self.userInfo.id
        newRequest.form['email'] = fromAddress
        newRequest.form['mesg'] = message
        newRequest.form['adminId'] = adminInfo.id

        txt = getMultiAdapter((self.context, newRequest),
                              name="request_message.txt")()
        html = getMultiAdapter((self.context, newRequest),
                               name="request_message.html")()
        try:
            sender.send_message(subject, txt, html, fromAddress)
        except ValueError:  # No valid email address
            m = 'Cannot send a "Request to join" notification to the administrator %s (%s) for '\
                'the group %s (%s) on %s (%s) because they lack a verified email address. '\
                'Skipping the notification.'
            log.warn(m, adminInfo.name, adminInfo.id, self.groupInfo.name,
                     self.groupInfo.id, self.siteInfo.name, self.siteInfo.id)
        self.request.response.setHeader(b'Content-Type', self.oldContentType)