예제 #1
0
 def get(self, feed_url, messageid):    
     
      
     existingUsers = UserDetails.gql("WHERE feedUrl = :1 LIMIT 1",feed_url) 
     for existingUser in existingUsers:
         email_name = existingUser.emailName
         account_exists = True
     USER_EMAIL = email_name + config.SETTINGS['emaildomain']       
     
     mId = int(messageid)
     accountExists = False   
     emailName = ""
     empty = True
             
     email = MailMessage.get_by_id(mId)   
     if email:
         empty = False
     
     feed_url = self.request.path.split('/')[2]
        
     prev_url = ""
     
     next_url = ""
            
         
     this_data = { 'email':email, 'to':USER_EMAIL, 'user':email_name, 'account_exists':account_exists, 'empty': empty, 'feed_url':feed_url[2], 'feed_url':feed_url, 'prev_url':prev_url}      
     
     app = App()
     view_data = app.data(this_data)
     
     path = os.path.join(main.ROOT_DIR, 'views/view/web-single.html')
     self.response.out.write(template.render(path, view_data))   
예제 #2
0
 def get(self, feed_url):                    
    
     account_exists = empty = False   
     emailName = ""
    
     
     existingUsers = UserDetails.gql("WHERE feedUrl = :1 LIMIT 1",feed_url) 
     for existingUser in existingUsers:
         email_name = existingUser.emailName
         account_exists = True
         
     if account_exists:
         feed_path = feed_url      
         feed_url = config.SETTINGS['url'] +"/"+ feed_url
          
         user_email = email_name + config.SETTINGS['emaildomain']           
         app = App()            
         
         emails = MailMessage.all().filter("toAddress = ", user_email).order("-dateReceived")      
         emailCount = emails.count() 
         if emailCount == 0:
             empty = True 
         this_data = { 'emails':emails, 'to':user_email,  'authControl':users.create_login_url("/"), 'empty': empty, 'feed_url':feed_url, 'feed_path':feed_path, 'account_exists':account_exists}      
                   
         
        
         view_data = app.data(this_data)
                 
         path = os.path.join(main.ROOT_DIR, 'views/view/web.html')
         self.response.out.write(template.render(path, view_data))
     else: 
         self.redirect("/#")      
예제 #3
0
    def receive(self, message):
        logging.info("Message from: " + message.sender + " to: " + message.to)
        original = message.original

        fromEmail = message.sender
        to = message.to
        blocked = trusted = accountExists = blockMode = False

        m = re.search("(?<=\<)(.*?)(?=\>)", to)  # serching for gmail formatted emails. ex: 'user <*****@*****.**>'
        if m:  # gmail format
            to = m.group()

        emailName, emailDomain = to.split("@")

        fm = re.search(
            "(?<=\<)(.*?)(?=\>)", fromEmail
        )  # serching for gmail formatted emails. ex: 'user <*****@*****.**>'
        if fm:  # gmail format
            fromEmail = fm.group()

        existingUsers = UserDetails.gql("WHERE emailName = :1 LIMIT 1", emailName)
        for existingUser in existingUsers:
            accountExists = True
            blockMode = existingUser.trustedMode

        logging.info("Forwarder start")
        if original.has_key("X-Forwarded-To"):
            logging.info("Forwarder hit")
            forwardEmail = original.get("X-Forwarded-To")
            to = forwardEmail
            emailName, emailDomain = forwardEmail.split("@")
            logging.info("Forwarder: " + str(forwardEmail) + " :: to " + emailName)
            existingUsers2 = UserDetails.gql("WHERE emailName = :1 LIMIT 1", str(emailName))
            for existingUser2 in existingUsers2:
                accountExists = True
                blockMode = existingUser2.trustedMode
                accountName = existingUser2.accountName
                logging.info("Account Exists via Forward: " + str(emailName))
                fromEmail = emailName

        if accountExists:
            mailMessage = MailMessage()
            mailMessage.toAddress = to
            mailMessage.fromAddress = message.sender
            mailMessage.subject = message.subject
            mailMessage.body = self._getBody(message)
            mailMessage.dateSent = message.date
            mailMessage.dateReceived = datetime.datetime.now()
            mailMessage.put()
        else:
            logging.info("Account does not exist " + message.to + " with an email name of " + emailName)
예제 #4
0
 def receive(self, message):
     logging.info("Received a message from: " + message.sender)
     mailMessage = MailMessage()
     mailMessage.toAddress = message.to
     mailMessage.fromAddress = message.sender
     mailMessage.subject = message.subject
     mailMessage.body = self._getBody(message)
     mailMessage.dateSent = message.date
     mailMessage.dateReceived = datetime.datetime.now()
     mailMessage.put()
     rcpt = Recipient.gql("where toAddress=:to", to=mailMessage.toAddress).get()
     if (not rcpt):
         Recipient(toAddress=mailMessage.toAddress).put();
     logging.warn(rcpt)
예제 #5
0
 def get(self, feed_url): 
     account_exists = False
     existingUsers = UserDetails.gql("WHERE feedUrl = :1 LIMIT 1",feed_url) 
     for existingUser in existingUsers:
         email_name = existingUser.emailName
         account_exists = True
     
     if account_exists:
         FEED_TITLE = email_name + " - email2feed"
         FEED_URL = "http://"+config.SETTINGS['hostname']+"/"+feed_url     
         FEED_URL_VIEW = "http://"+config.SETTINGS['hostname']+"/view/"+feed_url     
         USER_EMAIL = email_name + config.SETTINGS['emaildomain']  # ex. [email protected]  
         USER_LINK = config.SETTINGS['url'] + "/view/" + feed_url
         latestMessageVal = "";
         
         messages = MailMessage.all().filter("toAddress = ", USER_EMAIL).order("-dateReceived")
         results = messages.fetch(config.SETTINGS['maxfetch'])  
         
         latestEmailQry = MailMessage.all().filter("toAddress = ", USER_EMAIL).order("-dateReceived")
         latestMessageFtch = latestEmailQry.fetch(1)
         for latestMessage in latestMessageFtch:    
             latestMessageVal = latestMessage.dateReceived   
                 
         footer = "<div style='clear:both;text-align: right; width:100%'><span style='color:#4E83B9'>email<span style='color:#1A4979; font-weight: bold;'>2</span><span style='color:#4E83B9'>feed</span> | <a target='_blank' style='color:#4E83B9;text-decoration: none;' href='" + FEED_URL_VIEW + "'>settings</a></div>"        
                 
         this_data = {
                      "results"      :   results
                     ,"feedTitle"    :   FEED_TITLE
                     ,"feedUrl"      :   FEED_URL
                     ,"feedFooter"   :   footer
                     ,"updated"      :   latestMessageVal
                     ,"name"         :   email_name
                     ,"email"        :   USER_EMAIL
                     ,"userlink"     :   USER_LINK  
                     }     
         app = App()
         view_data = app.data(this_data)      
        
         
         self.response.headers['Content-Type'] = 'application/atom+xml'
         self.response.out.write(template.render("views/view/atom.xml", view_data))
     else:
         self.redirect("/#")
예제 #6
0
    def get(self):
        email = self.request.get("e")
        messages = MailMessage.all().filter("toAddress = ",email).order("-dateReceived")

        
        viewdata = { 'messages':messages
                    ,'to':email}

        path = os.path.join(main.ROOT_DIR, 'views/feed/show.html')
        self.response.out.write(template.render(path, viewdata))
예제 #7
0
 def get(self, feed_url):     
     account_exists = False
     existingUsers = UserDetails.gql("WHERE feedUrl = :1 LIMIT 1",feed_url) 
     for existingUser in existingUsers:
         email_name = existingUser.emailName
         account_exists = True
         
     if account_exists:
         FEED_TITLE = email_name + " - email2feed"
         FEED_URL = "http://"+config.SETTINGS['hostname']+"/rss/"+feed_url      
         USER_EMAIL = email_name + config.SETTINGS['emaildomain']  # ex. [email protected]
         USER_LINK = config.SETTINGS['url'] + "/view/" + feed_url   
         
         messages = MailMessage.all().filter("toAddress = ", USER_EMAIL).order("-dateReceived") #Get all emails for the current user     
         results = messages.fetch(config.SETTINGS['maxfetch'])  
         rss_items = []
         
         #Feed Message Data
         for msg in results:
             genlink = USER_LINK + "/" + str(msg.key().id())
             item = PyRSS2Gen.RSSItem(title=msg.subject,description=msg.body,pubDate=msg.dateReceived,guid = PyRSS2Gen.Guid(genlink),link=genlink) #subject, body, date received, test guid
             rss_items.append(item) 
 
         #Feed Title Data
         rss = PyRSS2Gen.RSS2(title=FEED_TITLE,
                              link=FEED_URL,
                              description=USER_EMAIL,
                              lastBuildDate=datetime.datetime.now(),
                              items=rss_items
                             )
         
         rss_xml = rss.to_xml()
         self.response.headers['Content-Type'] = 'application/rss+xml'
         self.response.out.write(rss_xml)
     else:
         self.redirect("/#")