Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread support #11

Closed
superfeedr opened this issue Feb 8, 2010 · 8 comments
Closed

Thread support #11

superfeedr opened this issue Feb 8, 2010 · 8 comments
Assignees

Comments

@superfeedr
Copy link

Hey, one of the great advantages of Gmail is threads... is there a way for a given message to retrieve th ethread?

Thanks!

@dcparker
Copy link
Owner

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!

@wkrsz
Copy link

wkrsz commented Nov 26, 2011

@wkrsz
Copy link

wkrsz commented Nov 26, 2011

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.

@wkrsz
Copy link

wkrsz commented Nov 26, 2011

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)

@alagu
Copy link

alagu commented Jan 25, 2012

Thanks @wojt-eu , that patch worked!

@wkrsz
Copy link

wkrsz commented Jan 25, 2012

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.

@myobie
Copy link
Collaborator

myobie commented Dec 19, 2012

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.

@ghost ghost assigned myobie Dec 19, 2012
@myobie
Copy link
Collaborator

myobie commented Mar 28, 2014

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.

@myobie myobie closed this as completed Mar 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants