aboutsummaryrefslogtreecommitdiff
path: root/lib/chotto/message_thread.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chotto/message_thread.rb')
-rw-r--r--lib/chotto/message_thread.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/chotto/message_thread.rb b/lib/chotto/message_thread.rb
new file mode 100644
index 0000000..87227cd
--- /dev/null
+++ b/lib/chotto/message_thread.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Chotto
+ class MessageThread
+ attr_reader :thread_id, :db
+
+ def initialize(thread_id:, db:)
+ @thread_id = thread_id
+ @db = db
+ end
+
+ def each
+ db.search_messages("thread:#{thread_id}").each do |msg|
+ yield(
+ Message.new(
+ msg: msg,
+ db: db
+ ))
+ end
+ end
+ end
+end