plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

reply by email to comments

Open jywarren opened this issue 11 years ago • 48 comments

For starters, here's the resource we're working from:

http://railscasts.com/episodes/313-receiving-email-with-mailman?view=asciicast

https://github.com/blog/811-reply-to-comments-from-email has some great conventions. I like how reliable and simple github email replies are.

Recommend first step could be a simple method in the Comment model, like this:

  def self.receive_mail(message)
    node_id = message.subject[/^\# (\d+)$/, 1] # this grabs the node ID from the subject line
    user_id = User.find_by(email: message.from.first)
    if node_id.present? && user_id.present?
      Comment.create! nid: node_id, body: message.body.decoded, uid: user_id
    end
  end

Then we need a mail script in the /script/ folder for something like the following:

#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"

Mailman.config.pop3 = {
  server: 'pop.gmail.com', port: 995, ssl: true,
  username: ENV['GMAIL_USERNAME'],
  password: ENV['GMAIL_PASSWORD']
}

Mailman::Application.run do
  default do
    begin
      Comment.receive_mail(message)
    rescue
      Mailman.logger.error "Exception occurred while receiving message:\n#{message}"
      Mailman.logger.error [e, *e.backtrace].join("\n")
    end
  end
end

Then we'll need to contact Sebastian to try to hook this up and we won't tell anyone about the feature just yet, but can try emailing a message with subject line: Replying to #6 from an email with a corresponding registered user on PublicLab.org, and see if it appends the new comment as we've laid out, on this post, which is nid=6: https://publiclab.org/notes/warren/12-7-2010/toy-spectrometers-arrived

I might have missed something, but let's see!

jywarren avatar Feb 21 '15 02:02 jywarren

Seems like this is an important functionality to have in place before we announce to the lists that we have the capability to support conversation entirely through our website.

ebarry avatar Sep 07 '16 15:09 ebarry

@jywarren So as you have stated above, GSoC 2017 has arrived and I could be working on this. I already created a feature branch for this and doing some experiments with mailman gem. And i'm checking for other solutions that could be used also. thanks.

aspriya avatar Feb 28 '17 15:02 aspriya

Hi @jywarren @ebarry working on it!!

ViditChitkara avatar Feb 14 '18 08:02 ViditChitkara

hi @ViditChitkara I guess its part of Email Integration project for this GSoC

grvsachdeva avatar Feb 14 '18 10:02 grvsachdeva

Yes, it is!! I have some plans about this for the soc 2018 program!!!

ViditChitkara avatar Feb 14 '18 10:02 ViditChitkara

Nice !!!.Actually, I have also planned to have my GSoC proposal on Email Integration Project.

grvsachdeva avatar Feb 14 '18 10:02 grvsachdeva

Cool!

ViditChitkara avatar Feb 14 '18 10:02 ViditChitkara

Sounds great -- there's plenty to do, so anything we can accomplish now we can build on, refine further for SoC for sure! Thanks!

On Wed, Feb 14, 2018 at 5:37 AM, Vidit [email protected] wrote:

Cool!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-365563045, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJweeuP1qvxLhzynG_TeUHFlhLOLDks5tUrdsgaJpZM4DjoxY .

jywarren avatar Feb 15 '18 15:02 jywarren

This is now working! Checklist for remaining parts might be:

  • [x] change sending email from do-not-reply@ to notifications@
  • [x] ensure it doesn't include the reply email content (there can be a lot) below the ...
  • [ ] Extend feature to Answer comment also. Anything else to break out here @namangupta01 ?

jywarren avatar Jun 26 '18 23:06 jywarren

yes we can also figure out if we can somehow write a test for it without using email services like mail file and we can also make function test for receive_mail.

namangupta01 avatar Jun 27 '18 11:06 namangupta01

Parsing email content depends upon the mail service we are using to do emails.

On Wed, Jun 27, 2018 at 5:00 AM Jeffrey Warren [email protected] wrote:

This is now working! Checklist for remaining parts might be:

  • change sending email from do-not-reply@ to notifications@
  • ensure it doesn't include the reply email content (there can be a lot) below the ...

Anything else to break out here @namangupta01 https://github.com/namangupta01 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-400494902, or mute the thread https://github.com/notifications/unsubscribe-auth/ATwCYdQRpw-BdNaVY5q7_6gAT12Y2VEhks5uAsQPgaJpZM4DjoxY .

namangupta01 avatar Jun 27 '18 13:06 namangupta01

This is github's testing reply parsing


From: Naman Gupta [email protected] Sent: Wednesday, June 27, 2018 7:05:11 PM To: publiclab/plots2 Cc: railsprojects2018; Manual Subject: Re: [publiclab/plots2] reply by email to comments (#214)

Parsing email content depends upon the mail service we are using to do emails.

On Wed, Jun 27, 2018 at 5:00 AM Jeffrey Warren [email protected] wrote:

This is now working! Checklist for remaining parts might be:

  • change sending email from do-not-reply@ to notifications@
  • ensure it doesn't include the reply email content (there can be a lot) below the ...

Anything else to break out here @namangupta01 https://github.com/namangupta01 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-400494902, or mute the thread https://github.com/notifications/unsubscribe-auth/ATwCYdQRpw-BdNaVY5q7_6gAT12Y2VEhks5uAsQPgaJpZM4DjoxY .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/publiclab/plots2/issues/214#issuecomment-400673514, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AmwIh0SuZQWP4SXxXqEC7w74iaVhYcatks5uA4oPgaJpZM4DjoxY.

railsprojects2018 avatar Jun 27 '18 13:06 railsprojects2018

@jywarren Above message is send using outlook email id. This message was not parsed correctly. Maybe github is also parsing gmail messages?

namangupta01 avatar Jun 27 '18 13:06 namangupta01

Above is send by outlook.

On Wed, Jun 27, 2018 at 7:06 PM railsprojects2018 [email protected] wrote:

This is github's testing reply parsing


From: Naman Gupta [email protected] Sent: Wednesday, June 27, 2018 7:05:11 PM To: publiclab/plots2 Cc: railsprojects2018; Manual Subject: Re: [publiclab/plots2] reply by email to comments (#214)

Parsing email content depends upon the mail service we are using to do emails.

On Wed, Jun 27, 2018 at 5:00 AM Jeffrey Warren [email protected] wrote:

This is now working! Checklist for remaining parts might be:

  • change sending email from do-not-reply@ to notifications@
  • ensure it doesn't include the reply email content (there can be a lot) below the ...

Anything else to break out here @namangupta01 https://github.com/namangupta01 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-400494902, or mute the thread < https://github.com/notifications/unsubscribe-auth/ATwCYdQRpw-BdNaVY5q7_6gAT12Y2VEhks5uAsQPgaJpZM4DjoxY

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub< https://github.com/publiclab/plots2/issues/214#issuecomment-400673514>, or mute the thread< https://github.com/notifications/unsubscribe-auth/AmwIh0SuZQWP4SXxXqEC7w74iaVhYcatks5uA4oPgaJpZM4DjoxY

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-400673841, or mute the thread https://github.com/notifications/unsubscribe-auth/ATwCYaCQh1gdATz5UQeJlxFI4FXj3G4tks5uA4pFgaJpZM4DjoxY .

namangupta01 avatar Jun 27 '18 13:06 namangupta01

This is send via yahooo On Wednesday, June 27, 2018, 7:28:02 PM GMT+5:30, Naman Gupta [email protected] wrote:

This is send by outlook.

On Wed, Jun 27, 2018 at 7:06 PM railsprojects2018 [email protected] wrote:

This is github's testing reply parsing


From: Naman Gupta [email protected] Sent: Wednesday, June 27, 2018 7:05:11 PM To: publiclab/plots2 Cc: railsprojects2018; Manual Subject: Re: [publiclab/plots2] reply by email to comments (#214)

Parsing email content depends upon the mail service we are using to do emails.

On Wed, Jun 27, 2018 at 5:00 AM Jeffrey Warren [email protected] wrote:

This is now working! Checklist for remaining parts might be:

  • change sending email from do-not-reply@ to notifications@
  • ensure it doesn't include the reply email content (there can be a lot) below the ...

Anything else to break out here @namangupta01 https://github.com/namangupta01 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-400494902, or mute the thread < https://github.com/notifications/unsubscribe-auth/ATwCYdQRpw-BdNaVY5q7_6gAT12Y2VEhks5uAsQPgaJpZM4DjoxY

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub< https://github.com/publiclab/plots2/issues/214#issuecomment-400673514>, or mute the thread< https://github.com/notifications/unsubscribe-auth/AmwIh0SuZQWP4SXxXqEC7w74iaVhYcatks5uA4oPgaJpZM4DjoxY

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/214#issuecomment-400673841, or mute the thread https://github.com/notifications/unsubscribe-auth/ATwCYaCQh1gdATz5UQeJlxFI4FXj3G4tks5uA4pFgaJpZM4DjoxY .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

railsprojects2018y avatar Jun 27 '18 14:06 railsprojects2018y

Above message is sent via yahoo. So the conclusion is that github only able to parse mails from gmail not other mails this may be because they are not able to trim emails from other services using any sphefic class or something like we were able to do in gmail using gmail_quote class. I think we can also able to do parsing from yahoo by using somewhat class like yahoo_quoted but other email services provide no such points to differentiate.

namangupta01 avatar Jun 27 '18 14:06 namangupta01

Perhaps there are examples of email quoting from various services that people have collected as a set of test strings? Or we could do the same?

jywarren avatar Jun 27 '18 14:06 jywarren

Also I like how the excess is hidden behind ...!

jywarren avatar Jun 27 '18 14:06 jywarren

Yes @jywarren i didn't find any collection but i am already collecting.

namangupta01 avatar Jun 27 '18 14:06 namangupta01

@jywarren Which of the email services should i collect? gmail, yahoo, hotmail, outlook any more?

namangupta01 avatar Jun 27 '18 15:06 namangupta01