Giter Site home page Giter Site logo

Thread support about ruby-gmail HOT 8 CLOSED

dcparker avatar dcparker commented on July 29, 2024
Thread support

from ruby-gmail.

Comments (8)

dcparker avatar dcparker commented on July 29, 2024

I don't know of any way right now, so no foreseeable way to add this -- BUT if anyone finds a way to get all emails of a certain Thread (Gmail conversations) via IMAP or some other way, please comment here!

from ruby-gmail.

wkrsz avatar wkrsz commented on July 29, 2024

http://code.google.com/apis/gmail/imap/#x-gm-thrid

from ruby-gmail.

wkrsz avatar wkrsz commented on July 29, 2024

data = gmail.imap.fetch(message.uid, "(X-GM-MSGID)")

I'm getting ParseError exception - Ruby's net/imap does not recognize the attribute.

I'm now trying to monkey-patch net/imap in the Large Hadron Collider.

from ruby-gmail.

wkrsz avatar wkrsz commented on July 29, 2024

Found the patch somewhere (adds two last when cases):

module Net
  class IMAP
    class ResponseParser 
      def msg_att
        match(T_LPAR)
        attr = {}
        while true
          token = lookahead
          case token.symbol
          when T_RPAR
            shift_token
            break
          when T_SPACE
            shift_token
            token = lookahead
          end
          case token.value
          when /\A(?:ENVELOPE)\z/ni
            name, val = envelope_data
          when /\A(?:FLAGS)\z/ni
            name, val = flags_data
          when /\A(?:INTERNALDATE)\z/ni
            name, val = internaldate_data
          when /\A(?:RFC822(?:\.HEADER|\.TEXT)?)\z/ni
            name, val = rfc822_text
          when /\A(?:RFC822\.SIZE)\z/ni
            name, val = rfc822_size
          when /\A(?:BODY(?:STRUCTURE)?)\z/ni
            name, val = body_data
          when /\A(?:UID)\z/ni
            name, val = uid_data

          when /\A(?:X-GM-MSGID)\z/ni  # Added X-GM-MSGID extension
            name, val = uid_data
          when /\A(?:X-GM-THRID)\z/ni  # Added X-GM-THRID extension
            name, val = uid_data

          else
            parse_error("unknown attribute `%s'", token.value)
          end
          attr[name] = val
        end
        return attr
      end

    end
  end
end

(I'll try to rework it to add only significant lines with alias_method or sth)

And then:

  data = gmail.imap.fetch(uid, "(X-GM-THRID)")
  thread_id =  data[0].attr["X-GM-THRID"].to_s(16)

from ruby-gmail.

alagu avatar alagu commented on July 29, 2024

Thanks @wojt-eu , that patch worked!

from ruby-gmail.

wkrsz avatar wkrsz commented on July 29, 2024

Glad to hear, @alagu. I recall I have tried to make the patch smaller (so that it didn't repeat whole msg_att method) but failed. It works though, It's used in production.

from ruby-gmail.

myobie avatar myobie commented on July 29, 2024

Is there a pull request for this anywhere? If not, I'll try to get this in as soon as I can get a test written.

from ruby-gmail.

myobie avatar myobie commented on July 29, 2024

I didn't find a PR for this and I don't want to monkey patch IMAP so I am going to close this. If there is another way to do this without modifying internals then please open a new issue.

from ruby-gmail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.