From: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com>
To: Sup developer discussion <sup-devel@rubyforge.org>
Subject: Re: [sup-devel] heliotrope-syncback
Date: Thu, 17 Nov 2011 02:33:07 +0100 [thread overview]
Message-ID: <CAMiZLn3kGuzMUxdMT1M0keSkZgggACWSbE3ykW+o6cdi-AiLkw@mail.gmail.com> (raw)
In-Reply-To: <CAMiZLn1+OFMu-Vht71iEVe6ohkC-kMHV1VE6CumEyvxpbEA2kA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 814 bytes --]
Hello,
I'm advancing on the IMAP interface. I can almost use OfflineIMAP, but
there are a few things :
- I needed an other method in the heliotrope-client file :
add-message. It is exactly like send_message but doesn't send it.
- I needed to have the msgid of a msg if it was already in the store,
so a few changes
Both of these are in the patch attached.
My problem now is that the addition of messages to the store doesn't
seem to work. I use the same things as in heliotrope-add :
force_encode("binary") if ...
@heliotropeclient.add_message ...
I send the whole rawbody to heliotrope. But when I want to see the
mail, the body is empty (turnsole says 0b, the web interface displays
only the header). I even used the RestClient directly, with no luck.
So where are my mistakes ?
--
Matthieu RAKOTOJAONA
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 2626 bytes --]
diff --git a/bin/heliotrope-server b/bin/heliotrope-server
index ed032eb..4f5748b 100644
--- a/bin/heliotrope-server
+++ b/bin/heliotrope-server
@@ -133,7 +133,8 @@ class HeliotropeServer < Sinatra::Base
begin
message = raw_body_to_message rawbody
if @metaindex.contains_safe_msgid? message.safe_msgid
- { :response => :ok, :status => :seen }
+ doc_id = @metaindex.fetch_docid_for_safe_msgid message.safe_msgid
+ { :response => :ok, :status => :seen, :doc_id => doc_id }
else
if @hooks.enabled? "before-add-message"
message, labels, state = @hooks.run "before-add-message", :message => message, :labels => labels, :state => state
diff --git a/lib/heliotrope-client.rb b/lib/heliotrope-client.rb
index 5499735..ecc8604 100644
--- a/lib/heliotrope-client.rb
+++ b/lib/heliotrope-client.rb
@@ -38,6 +38,12 @@ class HeliotropeClient
post_json "message/send", :message => message, :labels => opts[:labels].to_json, :state => opts[:state].to_json
end
+ def add_message message, opts={}
+ opts[:labels] ||= []
+ opts[:state] ||= []
+ post_json "message", :message => message, :labels => opts[:labels].to_json, :state => opts[:state].to_json
+ end
+
def bounce_message message, opts={}
opts[:force_recipients] ||= []
post_json "message/bounce", :message => message, :force_recipients => opts[:force_recipients].to_json
@@ -57,7 +63,9 @@ class HeliotropeClient
def info; get_json("info") end
def size; get_json("size")["size"] end
- def prune_labels!; post_json("labels/prune")["labels"] end
+ def prune_labels!
+ post_json("labels/prune")["labels"]
+ end
def set_labels! thread_id, labels
post_json "thread/#{thread_id}/labels", :labels => labels.to_json
@@ -95,7 +103,7 @@ private
raise Error, "invalid response: #{v.inspect[0..200]}" unless v.is_a?(Hash)
case v["response"]
when "ok"; v
- when "error"; raise Error, v["message"]
+ when "error"; raise Error, v.inspect
else raise Error, "invalid response: #{v.inspect[0..200]}"
end
rescue SystemCallError, RestClient::Exception, JSON::ParserError => e
diff --git a/lib/heliotrope/meta-index.rb b/lib/heliotrope/meta-index.rb
index 980ad5b..f68b88a 100644
--- a/lib/heliotrope/meta-index.rb
+++ b/lib/heliotrope/meta-index.rb
@@ -142,6 +142,11 @@ class MetaIndex
docid = load_int("rs2i/#{docid}") || docid
end
+ def fetch_docid_for_safe_msgid safe_msgid
+ load_int "docid/#{safe_msgid}"
+ end
+
+
def update_thread_state threadid, state
state = Set.new(state) & MESSAGE_MUTABLE_STATE
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
prev parent reply other threads:[~2011-11-17 2:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-02 23:55 Matthieu Rakotojaona
2011-11-07 6:57 ` William Morgan
2011-11-07 18:56 ` Michael Stapelberg
2011-11-09 3:22 ` Matthieu Rakotojaona
2011-11-09 23:18 ` William Morgan
2011-11-11 1:25 ` [sup-talk] " Matthieu Rakotojaona
2011-11-17 1:33 ` Matthieu Rakotojaona [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMiZLn3kGuzMUxdMT1M0keSkZgggACWSbE3ykW+o6cdi-AiLkw@mail.gmail.com \
--to=matthieu.rakotojaona@gmail.com \
--cc=sup-devel@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox