Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,4 @@ This project follows on Open Governance model. The Core Team is responsible for
* Copyright (c) 2010-2014 Kriss 'nu7hatch' Kowalik
* Copyright (c) 2009-2010 BehindLogic

Licensed under the MIT license. See [LICENSE](https://github.com/gmailgem/gmail/blob/master/LICENSE) for details.
Licensed under the MIT license. See [LICENSE](https://github.com/gmailgem/gmail/blob/master/LICENSE) for details.entrar
2 changes: 2 additions & 0 deletions lib/gmail/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class AuthorizationError < Net::IMAP::NoResponseError; end
class DeliveryError < ArgumentError; end
# Raised when given client is not registered
class UnknownClient < ArgumentError; end
# Raised when email not found
class EmailNotFound < ArgumentError; end

def self.clients
@clients ||= {}
Expand Down
6 changes: 6 additions & 0 deletions lib/gmail/client/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ def inbox
mailbox("INBOX")
end

# Functionality like rails #find method
def find(message_id)
message = mailbox('[Gmail]/All Mail').find(message_id: message_id).first
raise EmailNotFound, "Can't find message with ID #{message_id}" unless message
end

def mailboxes
@mailboxes ||= {}
end
Expand Down
1 change: 1 addition & 0 deletions lib/gmail/mailbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def fetch_uids(*args)
opts[:body] and search.concat ['BODY', opts[:body]]
opts[:uid] and search.concat ['UID', opts[:uid]]
opts[:gm] and search.concat ['X-GM-RAW', opts[:gm]]
opts[:message_id] and search.concat ['X-GM-MSGID', opts[:message_id]]
opts[:query] and search.concat opts[:query]

@gmail.mailbox(name) {
Expand Down
7 changes: 1 addition & 6 deletions lib/gmail/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,9 @@ def unarchive!
alias_method :unspam!, :unarchive!
alias_method :undelete!, :unarchive!

# Move to given box and delete from others.
# Apply a given label and optionally remove one.
# TODO: We should probably deprecate this method. It doesn't really add a lot
# of value, especially since the concept of "moving" a message from one
# label to another doesn't totally make sense in the Gmail world.
def move_to(name, from = nil)
add_label(name)
remove_label(from) if from
@gmail.find(message_id).remove_label(from) if from
end
alias_method :move, :move_to
alias_method :move!, :move_to
Expand Down