Skip to content

Instantly share code, notes, and snippets.

@tubbo
Created November 15, 2011 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubbo/1368091 to your computer and use it in GitHub Desktop.
Save tubbo/1368091 to your computer and use it in GitHub Desktop.
Diaspora Conversations Controller
class ConversationsController < ApplicationController
before_filter :authenticate_user!
respond_to :html, :json, :js
def index
page = params[:page]
id = params[:conversation_id]
@conversations = current_user.visible_conversations page
@visibilities = current_user.visibilities page
@conversation = current_user.visible_conversation id
end
def create
profle = params[:profile]
conv = params[:conversation]
ids = params[:contact_ids]
@conversation = current_user.create_converation_with_contacts conv, ids
status = @conversation ? :notice : :error
url = profile ? person_url(profile) : conversations_url(@conversation)
redirect_to url, status => I18n.t("conversations.create.#{status}")
end
def show
id = params[:id]
@conversation = current_user.visible_conversation id
if @conversation
@visibility = current_user.conversation_visibility params[:id]
respond_with @conversation
else
redirect_to conversations_path
end
end
def new
contact_id = params[:contact_id]
aspect_id = params[:aspect_id]
@contacts_json = current_user.all_contacts_and_ids
@contact_ids = case true
when contact_id then current_user.contacts_ids contact_id
when aspect_id then current_user.contacts_ids_from_aspects aspect_id
else
raise "Expects contact_id or aspect_id"
end
render :layout => false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment