Class: Protege::MessagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/protege/messages_controller.rb

Overview

Messages — the console email search and per-message delete, both keyed off the globally-unique message, so neither is thread-scoped.

index (+GET /messages+) is the cross-persona search view: query params filter the messages via MessageSearch and the matches render in the sidebar, each linking to its thread. destroy (+DELETE /messages/:id+) removes a single message by id.

Instance Method Summary collapse

Instance Method Details

#destroyvoid

This method returns an undefined value.

Delete a single message. Serves DELETE /messages/:id.

Responds with a Turbo Stream that removes the message element in place, or falls back to redirecting to its thread for non-Turbo requests.



28
29
30
31
32
33
34
35
# File 'app/controllers/protege/messages_controller.rb', line 28

def destroy
  @message.destroy!

  respond_to do |format|
    format.turbo_stream { render turbo_stream: turbo_stream.remove(@message) }
    format.html         { redirect_to thread_path(@message.email_thread) }
  end
end

#indexvoid

This method returns an undefined value.

Search emails across all threads. Serves GET /messages (+?from=&recipients=&subject=&body= &attachments=&page=+); blank params yield no results.



17
18
19
20
# File 'app/controllers/protege/messages_controller.rb', line 17

def index
  @search   = MessageSearch.from_params(params)
  @messages = @search.results
end