forked from diaspora/diaspora
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: app/controllers/status_messages_controller.rb app/models/data_point.rb app/models/status_message.rb db/schema.rb lib/fake.rb public/stylesheets/sass/application.sass spec/models/mention_spec.rb
- Loading branch information
Showing
113 changed files
with
2,682 additions
and
625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2010, Diaspora Inc. This file is | ||
# licensed under the Affero General Public License version 3 or later. See | ||
# the COPYRIGHT file. | ||
# | ||
|
||
class ConversationVisibilitiesController < ApplicationController | ||
before_filter :authenticate_user! | ||
|
||
def destroy | ||
@vis = ConversationVisibility.where(:person_id => current_user.person.id, | ||
:conversation_id => params[:conversation_id]).first | ||
if @vis | ||
if @vis.destroy | ||
flash[:notice] = "Conversation successfully removed" | ||
end | ||
end | ||
redirect_to conversations_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
class ConversationsController < ApplicationController | ||
before_filter :authenticate_user! | ||
|
||
respond_to :html, :json | ||
|
||
def index | ||
@conversations = Conversation.joins(:conversation_visibilities).where( | ||
:conversation_visibilities => {:person_id => current_user.person.id}).paginate( | ||
:page => params[:page], :per_page => 15, :order => 'updated_at DESC') | ||
|
||
@visibilities = ConversationVisibility.where( :person_id => current_user.person.id ).paginate( | ||
:page => params[:page], :per_page => 15, :order => 'updated_at DESC') | ||
|
||
@unread_counts = {} | ||
@visibilities.each{|v| @unread_counts[v.conversation_id] = v.unread} | ||
|
||
@authors = {} | ||
@conversations.each{|c| @authors[c.id] = c.last_author} | ||
|
||
@conversation = Conversation.joins(:conversation_visibilities).where( | ||
:conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first | ||
end | ||
|
||
def create | ||
person_ids = Contact.where(:id => params[:contact_ids].split(',')).map! do |contact| | ||
contact.person_id | ||
end | ||
|
||
params[:conversation][:participant_ids] = person_ids | [current_user.person.id] | ||
params[:conversation][:author] = current_user.person | ||
|
||
if @conversation = Conversation.create(params[:conversation]) | ||
Postzord::Dispatch.new(current_user, @conversation).post | ||
|
||
flash[:notice] = "Message sent" | ||
if params[:profile] | ||
redirect_to person_path(params[:profile]) | ||
else | ||
redirect_to conversations_path(:conversation_id => @conversation.id) | ||
end | ||
end | ||
end | ||
|
||
def show | ||
@conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id], | ||
:conversation_visibilities => {:person_id => current_user.person.id}).first | ||
|
||
if @visibility = ConversationVisibility.where(:conversation_id => params[:id], :person_id => current_user.person.id).first | ||
@visibility.unread = 0 | ||
@visibility.save | ||
end | ||
|
||
if @conversation | ||
render :layout => false | ||
else | ||
redirect_to conversations_path | ||
end | ||
end | ||
|
||
def new | ||
@all_contacts_and_ids = current_user.contacts.map{|c| {:value => c.id, :name => c.person.name}} | ||
@contact = current_user.contacts.find(params[:contact_id]) if params[:contact_id] | ||
render :layout => false | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2010, Diaspora Inc. This file is | ||
# licensed under the Affero General Public License version 3 or later. See | ||
# the COPYRIGHT file. | ||
|
||
class MessagesController < ApplicationController | ||
include ApplicationHelper | ||
before_filter :authenticate_user! | ||
|
||
respond_to :html, :mobile | ||
respond_to :json, :only => :show | ||
|
||
def create | ||
cnv = Conversation.joins(:conversation_visibilities).where(:id => params[:conversation_id], | ||
:conversation_visibilities => {:person_id => current_user.person.id}).first | ||
|
||
if cnv | ||
message = Message.new(:conversation_id => cnv.id, :text => params[:message][:text], :author => current_user.person) | ||
|
||
if message.save | ||
Rails.logger.info("event=create type=comment user=#{current_user.diaspora_handle} status=success message=#{message.id} chars=#{params[:message][:text].length}") | ||
Postzord::Dispatch.new(current_user, message).post | ||
|
||
redirect_to conversations_path(:conversation_id => cnv.id) | ||
else | ||
render :nothing => true, :status => 406 | ||
end | ||
else | ||
render :nothing => true, :status => 406 | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ConversationsHelper | ||
def new_message_text(count) | ||
if count > 0 | ||
t('new_messages', :count => count) | ||
else | ||
t('no_new_messages') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PrivateMessagesHelper | ||
end |
Oops, something went wrong.