示例#1
0
文件: emails.py 项目: steder/snippets
 def post(self):
     user = user_from_email(self.request.get('email'))
     d = date_for_retrieval()
     all_snippets = Snippet.all().filter("date =", d).fetch(500)
     all_users = User.all().fetch(500)
     following = compute_following(user, all_users)
     logging.info(all_snippets)
     body = '\n\n\n'.join([self.__snippet_to_text(s) for s in all_snippets if s.user.email in following])
     if body:
         self.__send_mail(user.email, 'https://snippetless.appspot.com\n\n' + body)
     else:
         logging.info(user.email + ' not following anybody.')
示例#2
0
文件: main.py 项目: tef/snippets
    def get(self, email):
        user = self.get_user()
        email = urllib.unquote_plus(email)
        desired_user = user_from_email(email)
        snippets = desired_user.snippet_set.filter("replaced =", False)
        snippets = sorted(snippets, key=lambda s: s.digest_date, reverse=True)
         
        template_values = {
                           'current_user' : user,
                           'user': desired_user,
                           'snippets': snippets,
                           'config': config

                           }
        self.render('user', template_values)
示例#3
0
文件: emails.py 项目: tef/snippets
    def post(self):
        user = user_from_email(self.request.get('email'))
        d = date_for_retrieval()
        all_snippets = Snippet.all().filter("digest_date =", d).filter("replaced =", False).fetch(500)
        logging.info(all_snippets)

        def snippet_to_text(snippet):
            divider = '-' * 30
            return '%s\n%s\n%s' % (snippet.user.pretty_name(), divider, snippet.text)

        body = '\n\n\n'.join(snippet_to_text(s) for s in all_snippets)

        if body:
            self.__send_mail(user.email, body)
        else:
            logging.info(user.email + 'not following anybody.')
    def receive(self, message):
        user = user_from_email(email.utils.parseaddr(message.sender)[1])
        for content_type, body in message.bodies('text/plain'):
            # http://stackoverflow.com/questions/4021392/how-do-you-decode-a-binary-encoded-mail-message-in-python
            if body.encoding == '8bit':
                body.encoding = '7bit'
            content = body.decode()

            sig_pattern = re.compile(r'^\-\-\s*$', re.MULTILINE)
            split_email = re.split(sig_pattern, content)
            content = split_email[0]

            reply_pattern = re.compile(r'^On.*at.*snippets', re.MULTILINE)
            split_email = re.split(reply_pattern, content)
            content = split_email[0]

            create_or_replace_snippet(user, content, date_for_new_snippet())
示例#5
0
 def get(self, email):
     user = self.get_user()
     email = urllib.unquote_plus(email)
     desired_user = user_from_email(email)
     snippets = desired_user.snippet_set
     snippets = sorted(snippets, key=lambda s: s.date, reverse=True)
     following = email in user.following 
     tags = [(t, t in user.tags_following) for t in desired_user.tags]
      
     template_values = {
                        'current_user' : user,
                        'user': desired_user,
                        'snippets': snippets,
                        'following': following,
                        'tags': tags
                        }
     self.render('user', template_values)
示例#6
0
    def receive(self, message):
        
        # todo: check it came to the right place? addressed_to = message.to.split(",")
        user = user_from_email(email.utils.parseaddr(message.sender)[1])
        for content_type, body in message.bodies('text/plain'):
            # http://stackoverflow.com/questions/4021392/how-do-you-decode-a-binary-encoded-mail-message-in-python
            if body.encoding == '8bit':
                body.encoding = '7bit'
            content = body.decode()

            sig_pattern = re.compile(r'^\-\-\s*$', re.MULTILINE)
            split_email = re.split(sig_pattern, content)
            content = split_email[0]

            output = []
            for line in content.splitlines(True):
                if not (line.startswith(">") or config.email in line):
                    output.append(line)

            content = "".join(output)

            if content.strip():
                create_or_replace_snippet(user, content, date_for_new_snippet(), datetime.datetime.now(London_tzinfo()))
示例#7
0
    def receive(self, message):
        # Added support for email aliases
        return_path = message.original.get('Return-Path')
        if return_path:
            canonical_from_address=return_path
        else:
            canonical_from_address=message.sender

        user = user_from_email(email.utils.parseaddr(canonical_from_address)[1])
        for content_type, body in message.bodies('text/plain'):
            # http://stackoverflow.com/questions/4021392/how-do-you-decode-a-binary-encoded-mail-message-in-python
            if body.encoding == '8bit':
                body.encoding = '7bit'
            content = body.decode()

            sig_pattern = re.compile(r'^\-\-\s*$', re.MULTILINE)
            split_email = re.split(sig_pattern, content)
            content = split_email[0]

            reply_pattern = re.compile(r'^On.*at.*Snippets', re.MULTILINE)
            split_email = re.split(reply_pattern, content)
            content = split_email[0]

            create_or_replace_snippet(user, content, date_for_new_snippet())