Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Close the "remove email->name mapping" issue
       [not found] <ea2d84848a9fed1fbceb3837aacf8bcf86bd0602.1227456947.git.nicolas.pouillard@gmail.com>
@ 2009-03-16 18:38 ` Nicolas Pouillard
  2009-03-16 18:38 ` [sup-talk] [PATCH] Remove the now useless PersonManager Nicolas Pouillard
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Pouillard @ 2009-03-16 18:38 UTC (permalink / raw)


Resent...

---
 ...e-aae5ae6378afa9bd2a8e1b15d28ba7ccef867791.yaml |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/bugs/issue-aae5ae6378afa9bd2a8e1b15d28ba7ccef867791.yaml b/bugs/issue-aae5ae6378afa9bd2a8e1b15d28ba7ccef867791.yaml
index cd3820d..83cc00a 100644
--- a/bugs/issue-aae5ae6378afa9bd2a8e1b15d28ba7ccef867791.yaml
+++ b/bugs/issue-aae5ae6378afa9bd2a8e1b15d28ba7ccef867791.yaml
@@ -5,8 +5,8 @@ type: :bugfix
 component: sup
 release: 
 reporter: William Morgan <wmorgan-sup at masanjin.net>
-status: :unstarted
-disposition: 
+status: :closed
+disposition: :fixed
 creation_time: 2008-05-19 23:42:25.910550 Z
 references: []
 
@@ -20,4 +20,8 @@ log_events:
   - William Morgan <wmorgan-sup at masanjin.net>
   - unassigned from release 0.6
   - ""
+- - 2008-11-22 16:31:27.450146 Z
+  - Nicolas Pouillard <nicolas.pouillard at gmail.com>
+  - closed with disposition fixed
+  - This mapping and the PersonManager are now removed.
 git_branch: 

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [PATCH] Remove the now useless PersonManager
       [not found] <ea2d84848a9fed1fbceb3837aacf8bcf86bd0602.1227456947.git.nicolas.pouillard@gmail.com>
  2009-03-16 18:38 ` [sup-talk] [PATCH] Close the "remove email->name mapping" issue Nicolas Pouillard
@ 2009-03-16 18:38 ` Nicolas Pouillard
  2009-03-25 16:00   ` William Morgan
  1 sibling, 1 reply; 4+ messages in thread
From: Nicolas Pouillard @ 2009-03-16 18:38 UTC (permalink / raw)


Resent..

Replace PersonManager.person_for by Person.from_address
and PersonManager.people_for by Person.from_address_list
---
 lib/sup.rb                         |    1 -
 lib/sup/buffer.rb                  |    2 +-
 lib/sup/contact.rb                 |    2 +-
 lib/sup/index.rb                   |    4 ++--
 lib/sup/message.rb                 |   16 ++++++++--------
 lib/sup/modes/edit-message-mode.rb |    6 +++---
 lib/sup/modes/reply-mode.rb        |    2 +-
 lib/sup/modes/thread-view-mode.rb  |    4 ++--
 lib/sup/person.rb                  |   22 +++++-----------------
 9 files changed, 23 insertions(+), 36 deletions(-)

diff --git a/lib/sup.rb b/lib/sup.rb
index d833dff..b3ebd38 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -114,7 +114,6 @@ module Redwood
   end
 
   def start
-    Redwood::PersonManager.new
     Redwood::SentManager.new Redwood::SENT_FN
     Redwood::ContactManager.new Redwood::CONTACT_FN
     Redwood::LabelManager.new Redwood::LABEL_FN
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index 0447f61..657027d 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -506,7 +506,7 @@ EOS
     answer = BufferManager.ask_many_emails_with_completions domain, question, completions, default
 
     if answer
-      answer.split_on_commas.map { |x| ContactManager.contact_for(x) || PersonManager.person_for(x) }
+      answer.split_on_commas.map { |x| ContactManager.contact_for(x) || Person.from_address(x) }
     end
   end
 
diff --git a/lib/sup/contact.rb b/lib/sup/contact.rb
index bbb872f..51fd0e9 100644
--- a/lib/sup/contact.rb
+++ b/lib/sup/contact.rb
@@ -17,7 +17,7 @@ class ContactManager
       IO.foreach(fn) do |l|
         l =~ /^([^:]*): (.*)$/ or raise "can't parse #{fn} line #{l.inspect}"
         aalias, addr = $1, $2
-        p = PersonManager.person_for addr
+        p = Person.from_address addr
         @p2a[p] = aalias
         @a2p[aalias] = p unless aalias.nil? || aalias.empty?
       end
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index cda5cee..d2e58ce 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -447,9 +447,9 @@ EOS
         t = @index[docid][:to]
 
         if AccountManager.is_account_email? f
-          t.split(" ").each { |e| contacts[PersonManager.person_for(e)] = true }
+          t.split(" ").each { |e| contacts[Person.from_address(e)] = true }
         else
-          contacts[PersonManager.person_for(f)] = true
+          contacts[Person.from_address(f)] = true
         end
       end
     end
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index e01e245..88d9ce3 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -78,10 +78,10 @@ class Message
     
     @from =
       if header["from"]
-        PersonManager.person_for header["from"]
+        Person.from_address header["from"]
       else
         fakename = "Sup Auto-generated Fake Sender <sup at fake.sender.example.com>"
-        PersonManager.person_for fakename
+        Person.from_address fakename
       end
 
     Redwood::log "faking message-id for message from #@from: #{id}" if fakeid
@@ -105,9 +105,9 @@ class Message
       end
 
     @subj = header.member?("subject") ? header["subject"].gsub(/\s+/, " ").gsub(/\s+$/, "") : DEFAULT_SUBJECT
-    @to = PersonManager.people_for header["to"]
-    @cc = PersonManager.people_for header["cc"]
-    @bcc = PersonManager.people_for header["bcc"]
+    @to = Person.from_address_list header["to"]
+    @cc = Person.from_address_list header["cc"]
+    @bcc = Person.from_address_list header["bcc"]
 
     ## before loading our full header from the source, we can actually
     ## have some extra refs set by the UI. (this happens when the user
@@ -117,10 +117,10 @@ class Message
     @refs = (@refs + refs).uniq
     @replytos = (header["in-reply-to"] || "").scan(/<(.+?)>/).map { |x| sanitize_message_id x.first }
 
-    @replyto = PersonManager.person_for header["reply-to"]
+    @replyto = Person.from_address header["reply-to"]
     @list_address =
       if header["list-post"]
-        @list_address = PersonManager.person_for header["list-post"].gsub(/^<mailto:|>$/, "")
+        @list_address = Person.from_address header["list-post"].gsub(/^<mailto:|>$/, "")
       else
         nil
       end
@@ -391,7 +391,7 @@ private
     elsif m.header.content_type == "message/rfc822"
       payload = RMail::Parser.read(m.body)
       from = payload.header.from.first
-      from_person = from ? PersonManager.person_for(from.format) : nil
+      from_person = from ? Person.from_address(from.format) : nil
       [Chunk::EnclosedMessage.new(from_person, payload.to_s)] +
         message_to_chunks(payload, encrypted)
     else
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index cc6e7af..31aa897 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -321,8 +321,8 @@ protected
 
     ## do whatever crypto transformation is necessary
     if @crypto_selector && @crypto_selector.val != :none
-      from_email = PersonManager.person_for(@header["From"]).email
-      to_email = [@header["To"], @header["Cc"], @header["Bcc"]].flatten.compact.map { |p| PersonManager.person_for(p).email }
+      from_email = Person.from_address(@header["From"]).email
+      to_email = [@header["To"], @header["Cc"], @header["Bcc"]].flatten.compact.map { |p| Person.from_address(p).email }
 
       m = CryptoManager.send @crypto_selector.val, from_email, to_email, m
     end
@@ -412,7 +412,7 @@ private
   end
 
   def sig_lines
-    p = PersonManager.person_for(@header["From"])
+    p = Person.from_address(@header["From"])
     from_email = p && p.email
 
     ## first run the hook
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index 4e08e8e..c1c542b 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -63,7 +63,7 @@ EOS
       if hook_reply_from
         hook_reply_from
       elsif @m.recipient_email && AccountManager.is_account_email?(@m.recipient_email)
-        PersonManager.person_for(@m.recipient_email)
+        Person.from_address(@m.recipient_email)
       elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
         b
       else
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 5f578d3..45c1247 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -148,7 +148,7 @@ EOS
   def subscribe_to_list
     m = @message_lines[curpos] or return
     if m.list_subscribe && m.list_subscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
-      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [Person.from_address($1)], :subj => $3
     else
       BufferManager.flash "Can't find List-Subscribe header for this message."
     end
@@ -157,7 +157,7 @@ EOS
   def unsubscribe_from_list
     m = @message_lines[curpos] or return
     if m.list_unsubscribe && m.list_unsubscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
-      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [Person.from_address($1)], :subj => $3
     else
       BufferManager.flash "Can't find List-Unsubscribe header for this message."
     end
diff --git a/lib/sup/person.rb b/lib/sup/person.rb
index 995620b..ca70351 100644
--- a/lib/sup/person.rb
+++ b/lib/sup/person.rb
@@ -1,22 +1,5 @@
 module Redwood
 
-class PersonManager
-  include Singleton
-
-  def initialize
-    self.class.i_am_the_instance self
-  end
-
-  def self.people_for s
-    return [] if s.nil?
-    s.split_on_commas.map { |ss| self.person_for ss }
-  end
-
-  def self.person_for s
-    Person.from_address(s)
-  end
-end
-
 class Person 
   attr_accessor :name, :email
 
@@ -110,6 +93,11 @@ class Person
     Person.new name, email
   end
 
+  def self.from_address_list ss
+    return [] if ss.nil?
+    ss.split_on_commas.map { |s| self.from_address s }
+  end
+
   def indexable_content
     [name, email, email.split(/@/).first].join(" ")
   end

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [PATCH] Remove the now useless PersonManager
  2009-03-16 18:38 ` [sup-talk] [PATCH] Remove the now useless PersonManager Nicolas Pouillard
@ 2009-03-25 16:00   ` William Morgan
  2009-03-25 18:03     ` Nicolas Pouillard
  0 siblings, 1 reply; 4+ messages in thread
From: William Morgan @ 2009-03-25 16:00 UTC (permalink / raw)


I've placed these two, and the previous patch about removing people.txt,
on the branch dont-canonicalize-email-addresses, merged into next. I've
added a couple commits that fix email parsing from the index, and that
save the new email addresses to the index when saving an email. I think
this is pretty close to fixing the problem.

I'm going to send out a summary of this issue and a couple other
interesting bits of the next branch shortly.
-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [sup-talk] [PATCH] Remove the now useless PersonManager
  2009-03-25 16:00   ` William Morgan
@ 2009-03-25 18:03     ` Nicolas Pouillard
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Pouillard @ 2009-03-25 18:03 UTC (permalink / raw)


Excerpts from William Morgan's message of Wed Mar 25 17:00:35 +0100 2009:
> I've placed these two, and the previous patch about removing people.txt,
> on the branch dont-canonicalize-email-addresses, merged into next. I've
> added a couple commits that fix email parsing from the index, and that
> save the new email addresses to the index when saving an email. I think
> this is pretty close to fixing the problem.

Great this set of patches was indeed somewhat half baked.

> I'm going to send out a summary of this issue and a couple other
> interesting bits of the next branch shortly.

A lot of great stuffs!

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-25 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ea2d84848a9fed1fbceb3837aacf8bcf86bd0602.1227456947.git.nicolas.pouillard@gmail.com>
2009-03-16 18:38 ` [sup-talk] [PATCH] Close the "remove email->name mapping" issue Nicolas Pouillard
2009-03-16 18:38 ` [sup-talk] [PATCH] Remove the now useless PersonManager Nicolas Pouillard
2009-03-25 16:00   ` William Morgan
2009-03-25 18:03     ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox