social_stream 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -12
- data/app/controllers/activities_controller.rb +17 -1
- data/app/controllers/api_controller.rb +2 -2
- data/app/controllers/avatars_controller.rb +44 -0
- data/app/controllers/contacts_controller.rb +13 -21
- data/app/controllers/conversations_controller.rb +107 -0
- data/app/controllers/groups_controller.rb +7 -11
- data/app/controllers/messages_controller.rb +21 -88
- data/app/controllers/profiles_controller.rb +3 -1
- data/app/controllers/pshb_controller.rb +37 -1
- data/app/controllers/ties_controller.rb +7 -8
- data/app/controllers/users_controller.rb +19 -43
- data/app/helpers/location_helper.rb +34 -0
- data/app/helpers/subjects_helper.rb +18 -1
- data/app/models/activity.rb +67 -27
- data/app/models/activity_verb.rb +1 -1
- data/app/models/actor.rb +85 -37
- data/app/models/avatar.rb +90 -0
- data/app/models/group.rb +2 -2
- data/app/models/profile.rb +8 -0
- data/app/models/tie.rb +20 -22
- data/app/models/user.rb +2 -8
- data/app/views/activities/_index.html.erb +22 -0
- data/app/views/activities/_options.html.erb +3 -1
- data/app/views/activities/_root.html.erb +4 -2
- data/app/views/activities/_walls.html.erb +34 -0
- data/app/views/activities/index.js.erb +1 -0
- data/app/views/avatars/_form.html.erb +23 -0
- data/app/views/{logos → avatars}/_precrop.html.erb +23 -15
- data/app/views/avatars/edit.html.erb +6 -0
- data/app/views/avatars/index.html.erb +42 -0
- data/app/views/{logos → avatars}/new.html.erb +7 -11
- data/app/views/avatars/show.html.erb +5 -0
- data/app/views/contacts/_index.html.erb +33 -0
- data/app/views/contacts/index.html.erb +35 -2
- data/app/views/contacts/index.js.erb +1 -0
- data/app/views/conversations/_conversation.html.erb +37 -0
- data/app/views/conversations/_conversation_full.html.erb +52 -0
- data/app/views/{messages → conversations}/_conversations.html.erb +2 -1
- data/app/views/conversations/_index.html.erb +23 -0
- data/app/views/{messages → conversations}/_menu_options.html.erb +2 -2
- data/app/views/conversations/_show.html.erb +21 -0
- data/app/views/{messages → conversations}/edit.html.erb +0 -0
- data/app/views/{messages → conversations}/index.html.erb +1 -3
- data/app/views/conversations/index.js.erb +7 -0
- data/app/views/conversations/show.html.erb +47 -0
- data/app/views/conversations/show.js.erb +39 -0
- data/app/views/frontpage/_header.html.erb +5 -1
- data/app/views/groups/_new.html.erb +50 -48
- data/app/views/groups/_sidebar_show.html.erb +1 -1
- data/app/views/groups/index.html.erb +1 -1
- data/app/views/groups/new.html.erb +6 -1
- data/app/views/groups/show.html.erb +1 -3
- data/app/views/home/_menu.html.erb +46 -0
- data/app/views/home/_sidebar.html.erb +12 -0
- data/app/views/home/index.html.erb +3 -3
- data/app/views/layouts/application.html.erb +1 -1
- data/app/views/layouts/test.html +58 -41
- data/app/views/location/_location.html.erb +3 -0
- data/app/views/messages/_form.html.erb +5 -52
- data/app/views/messages/_message.html.erb +31 -0
- data/app/views/messages/_new.html.erb +10 -16
- data/app/views/messages/new.html.erb +48 -3
- data/app/views/messages/new.js.erb +38 -1
- data/app/views/profiles/_profile.html.erb +194 -0
- data/app/views/profiles/edit.html.erb +168 -0
- data/app/views/profiles/show.html.erb +2 -175
- data/app/views/{users → profiles}/update.js.erb +12 -15
- data/app/views/subjects/_contacts.html.erb +2 -3
- data/app/views/subjects/_toolbar_home.html.erb +1 -1
- data/app/views/subjects/_toolbar_home_menu.html.erb +4 -1
- data/app/views/subjects/_toolbar_home_menu_options.html.erb +4 -7
- data/app/views/subjects/_toolbar_home_menu_options_subjects.html.erb +0 -3
- data/app/views/subjects/_toolbar_logo.html.erb +1 -1
- data/app/views/subjects/_toolbar_message_menu.html.erb +17 -0
- data/app/views/subjects/_toolbar_profile.html.erb +4 -12
- data/app/views/subjects/_toolbar_profile_menu.html.erb +9 -10
- data/app/views/subjects/_toolbar_profile_menu_basic_options.html.erb +6 -5
- data/app/views/subjects/_toolbar_profile_menu_tie_options.html.erb +13 -13
- data/app/views/ties/_new.html.erb +30 -25
- data/app/views/ties/_suggestions.html.erb +1 -0
- data/app/views/ties/new.js.erb +2 -0
- data/app/views/users/_index.html.erb +1 -1
- data/app/views/users/index.html.erb +1 -3
- data/app/views/users/show.html.erb +4 -3
- data/config/locales/en.yml +79 -24
- data/config/routes.rb +8 -2
- data/lib/generators/social_stream/install_generator.rb +1 -1
- data/lib/generators/social_stream/templates/migration.rb +17 -11
- data/lib/generators/social_stream/templates/public/images/btn/message_conversation.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/message_inbox.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/message_new.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/message_sentbox.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/message_trash.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/ajax.paginate.js +1 -1
- data/lib/generators/social_stream/templates/public/javascripts/menu.js +9 -99
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +14 -5
- data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +1 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery-ui.css +13 -10
- data/lib/generators/social_stream/templates/public/stylesheets/default/menu.css +5 -11
- data/lib/generators/social_stream/templates/public/stylesheets/default/messages.css +96 -20
- data/lib/generators/social_stream/templates/relations.yml +1 -0
- data/lib/paperclip/social_stream.rb +1 -1
- data/lib/social_stream/ability.rb +1 -0
- data/lib/social_stream/controllers/helpers.rb +20 -0
- data/lib/social_stream/models/subject.rb +13 -12
- data/lib/social_stream/rails.rb +4 -1
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +14 -4
- data/social_stream.gemspec +31 -5
- data/spec/controllers/contacts_controller_spec.rb +6 -0
- data/spec/controllers/profiles_controller_spec.rb +3 -4
- data/spec/dummy/config/initializers/devise.rb +4 -1
- data/spec/dummy/config/relations.yml +1 -0
- data/spec/models/activity_spec.rb +24 -0
- metadata +91 -89
- data/app/controllers/logos_controller.rb +0 -37
- data/app/models/logo.rb +0 -88
- data/app/views/activities/_activities.html.erb +0 -46
- data/app/views/groups/_profile.html.erb +0 -142
- data/app/views/groups/edit.html.erb +0 -135
- data/app/views/groups/update.js.erb +0 -39
- data/app/views/logos/_form.html.erb +0 -33
- data/app/views/logos/edit.html.erb +0 -6
- data/app/views/logos/index.html.erb +0 -27
- data/app/views/logos/show.html.erb +0 -5
- data/app/views/menu/_group.html.erb +0 -15
- data/app/views/menu/_home_user.html.erb +0 -0
- data/app/views/menu/_optionsGroups.html.erb +0 -11
- data/app/views/menu/_optionsUser.html.erb +0 -11
- data/app/views/menu/_services.html.erb +0 -11
- data/app/views/menu/_tiesGroup.html.erb +0 -14
- data/app/views/menu/_tiesUser.html.erb +0 -11
- data/app/views/menu/_user.html.erb +0 -15
- data/app/views/messages/_conversation.html.erb +0 -34
- data/app/views/messages/_conversation_full.html.erb +0 -65
- data/app/views/messages/_index.html.erb +0 -19
- data/app/views/messages/_location.html.erb +0 -3
- data/app/views/messages/_show.html.erb +0 -22
- data/app/views/messages/index.js.erb +0 -1
- data/app/views/messages/show.html.erb +0 -10
- data/app/views/messages/show.js.erb +0 -1
- data/app/views/users/_profile.html.erb +0 -171
- data/app/views/users/_sidebar_show.html.erb +0 -1
- data/app/views/users/edit.html.erb +0 -194
data/Rakefile
CHANGED
@@ -25,16 +25,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
25
25
|
rdoc.rdoc_files.include('lib/**/*.rb', 'app/**/*.rb')
|
26
26
|
end
|
27
27
|
|
28
|
-
class Bundler::GemHelper
|
29
|
-
def install_gem
|
30
|
-
built_gem_path = build_gem
|
31
|
-
out, err, code = sh_with_code("sudo gem install #{built_gem_path} --no-rdoc --no-ri")
|
32
|
-
if err[/ERROR/]
|
33
|
-
Bundler.ui.error err
|
34
|
-
else
|
35
|
-
Bundler.ui.confirm "#{name} (#{version}) installed"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
28
|
Bundler::GemHelper.install_tasks
|
@@ -1,2 +1,18 @@
|
|
1
|
-
class ActivitiesController <
|
1
|
+
class ActivitiesController < InheritedResources::Base
|
2
|
+
belongs_to_subjects
|
3
|
+
|
4
|
+
respond_to :js
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
def collection
|
9
|
+
rel = params[:section].to_i if params[:section].present?
|
10
|
+
|
11
|
+
# should be activities.paginate(:page => params[:page], :count => { :select => 'activity.id', :distinct => true }) but it is not working in Rails 3.0.3
|
12
|
+
@activities ||= association_chain[-1].
|
13
|
+
wall(:profile,
|
14
|
+
:for => current_subject,
|
15
|
+
:relation => rel).
|
16
|
+
paginate(:page => params[:page])
|
17
|
+
end
|
2
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class ApiController < ApplicationController
|
2
2
|
|
3
|
-
before_filter :authenticate_user!, :only => [:create_key, :users
|
3
|
+
before_filter :authenticate_user!, :only => [:create_key, :users]#, :activity_atom_feed]
|
4
4
|
|
5
5
|
def create_key
|
6
6
|
current_user.reset_authentication_token!
|
@@ -26,7 +26,7 @@ class ApiController < ApplicationController
|
|
26
26
|
end
|
27
27
|
|
28
28
|
@page = params[:page]
|
29
|
-
@activities =
|
29
|
+
@activities = @user.wall(:home).paginate(:page => params[:page], :per_page => 10)
|
30
30
|
respond_to do |format|
|
31
31
|
format.atom
|
32
32
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class AvatarsController < InheritedResources::Base
|
2
|
+
|
3
|
+
before_filter :authenticate_user!
|
4
|
+
def update
|
5
|
+
|
6
|
+
if !current_subject.avatars.blank?
|
7
|
+
|
8
|
+
new_logo = Avatar.find(params[:id])
|
9
|
+
|
10
|
+
if (new_logo.actor == current_subject.actor)
|
11
|
+
|
12
|
+
actual_logo = current_subject.avatars.active.first
|
13
|
+
if !actual_logo.blank?
|
14
|
+
actual_logo.active = false
|
15
|
+
actual_logo.save
|
16
|
+
end
|
17
|
+
|
18
|
+
new_logo.active = true
|
19
|
+
new_logo.save
|
20
|
+
end
|
21
|
+
end
|
22
|
+
redirect_to avatars_path
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@avatar = Avatar.create(params[:logo])
|
27
|
+
|
28
|
+
if @avatar.new_record?
|
29
|
+
render :new
|
30
|
+
else
|
31
|
+
@avatar.updating_logo = true
|
32
|
+
@avatar.actor_id = current_subject.actor.id
|
33
|
+
if !current_subject.avatars.blank?
|
34
|
+
actual_logo = current_subject.avatars.active.first
|
35
|
+
actual_logo.active = false
|
36
|
+
actual_logo.save
|
37
|
+
end
|
38
|
+
@avatar.active = true
|
39
|
+
@avatar.save
|
40
|
+
redirect_to [current_subject, :profile]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -1,28 +1,20 @@
|
|
1
1
|
class ContactsController < ApplicationController
|
2
|
+
before_filter :authenticate_user!
|
2
3
|
|
3
4
|
def index
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#Fill the array with actor name/actorId of all the actors which has a tie with current_subject
|
14
|
-
mySubjects.each do |aSubject|
|
15
|
-
aSubjectD = {}
|
16
|
-
aSubjectD['key'] = aSubject.name
|
17
|
-
aSubjectD['value'] = aSubject.actor_id.to_s
|
18
|
-
myContacts << aSubjectD
|
19
|
-
end
|
20
|
-
|
5
|
+
@contacts =
|
6
|
+
current_subject.
|
7
|
+
contacts(:direction => :sent){ |q|
|
8
|
+
q.alphabetic.
|
9
|
+
letter(params[:letter]).
|
10
|
+
search(params[:search]).
|
11
|
+
merge(Tie.original.related_by(current_subject.relations.find_by_id(params[:relation])))
|
12
|
+
}
|
13
|
+
|
21
14
|
respond_to do |format|
|
22
|
-
format.html
|
23
|
-
format.
|
15
|
+
format.html { @contacts = @contacts.paginate(:page => params[:page], :per_page => 10) }
|
16
|
+
format.js { @contacts = @contacts.paginate(:page => params[:page], :per_page => 10) }
|
17
|
+
format.json { render :text => @contacts.map{ |c| { 'key' => c.name, 'value' => c.actor_id.to_s } }.to_json }
|
24
18
|
end
|
25
|
-
|
26
19
|
end
|
27
|
-
|
28
20
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
class ConversationsController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :get_mailbox, :get_box, :get_actor
|
4
|
+
def index
|
5
|
+
if @box.eql?"inbox"
|
6
|
+
@conversations = @mailbox.inbox.paginate(:per_page => 9, :page => params[:page])
|
7
|
+
elsif @box.eql?"sentbox"
|
8
|
+
@conversations = @mailbox.sentbox.paginate(:per_page => 9, :page => params[:page])
|
9
|
+
else
|
10
|
+
@conversations = @mailbox.trash.paginate(:per_page => 9, :page => params[:page])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
@conversation = Conversation.find_by_id(params[:id])
|
16
|
+
if @conversation.nil? or !@conversation.is_participant?(@actor)
|
17
|
+
redirect_to conversations_path(:box => @box)
|
18
|
+
return
|
19
|
+
end
|
20
|
+
if @box.eql? 'trash'
|
21
|
+
@receipts = @conversation.receipts(@actor).trash
|
22
|
+
else
|
23
|
+
@receipts = @conversation.receipts(@actor).not_trash
|
24
|
+
end
|
25
|
+
render :action => :show
|
26
|
+
@receipts.mark_as_read
|
27
|
+
end
|
28
|
+
|
29
|
+
def new
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def create
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
@conversation = Conversation.find_by_id(params[:id])
|
43
|
+
if @conversation.nil? or !@conversation.is_participant?(@actor)
|
44
|
+
redirect_to conversations_path(:box => @box)
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
if params[:untrash].present?
|
49
|
+
@conversation.untrash(@actor)
|
50
|
+
end
|
51
|
+
|
52
|
+
if params[:reply_all].present?
|
53
|
+
last_receipt = @conversation.receipts(@actor).last
|
54
|
+
@receipt = @actor.reply_to_all(last_receipt, params[:body])
|
55
|
+
end
|
56
|
+
|
57
|
+
if @box.eql? 'trash'
|
58
|
+
@receipts = @conversation.receipts(@actor).trash
|
59
|
+
else
|
60
|
+
@receipts = @conversation.receipts(@actor).not_trash
|
61
|
+
end
|
62
|
+
render :action => :show
|
63
|
+
@receipts.mark_as_read
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy
|
68
|
+
@conversation = Conversation.find_by_id(params[:id])
|
69
|
+
if @conversation.nil? or !@conversation.is_participant?(@actor)
|
70
|
+
redirect_to conversations_path(:box => @box)
|
71
|
+
return
|
72
|
+
end
|
73
|
+
|
74
|
+
@conversation.move_to_trash(@actor)
|
75
|
+
|
76
|
+
if params[:location].present?
|
77
|
+
case params[:location]
|
78
|
+
when 'conversation'
|
79
|
+
redirect_to conversations_path(:box => :trash)
|
80
|
+
return
|
81
|
+
else
|
82
|
+
redirect_to conversations_path(:box => @box,:page => params[:page])
|
83
|
+
return
|
84
|
+
end
|
85
|
+
end
|
86
|
+
redirect_to conversations_path(:box => @box,:page => params[:page])
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def get_mailbox
|
92
|
+
@mailbox = current_subject.mailbox
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_actor
|
96
|
+
@actor = Actor.normalize(current_subject)
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_box
|
100
|
+
if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
|
101
|
+
@box = "inbox"
|
102
|
+
return
|
103
|
+
end
|
104
|
+
@box = params[:box]
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
class GroupsController < InheritedResources::Base
|
2
|
-
|
3
2
|
respond_to :html, :xml, :js
|
4
3
|
|
5
4
|
def index
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
5
|
+
@groups = Group.alphabetic.
|
6
|
+
letter(params[:letter]).
|
7
|
+
search(params[:search]).
|
8
|
+
paginate(:per_page => 10, :page => params[:page])
|
9
|
+
|
10
|
+
index! do |format|
|
11
|
+
format.html { render :layout => (user_signed_in? ? 'application' : 'frontpage') }
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
15
|
protected
|
20
16
|
|
21
17
|
# Overwrite resource method to support slug
|
@@ -1,32 +1,15 @@
|
|
1
1
|
class MessagesController < ApplicationController
|
2
2
|
|
3
|
-
before_filter :get_mailbox, :get_box
|
4
|
-
def index
|
5
|
-
if @box.eql?"inbox"
|
6
|
-
@conversations = @mailbox.inbox.paginate(:per_page => 9, :page => params[:page])
|
7
|
-
elsif @box.eql?"sentbox"
|
8
|
-
@conversations = @mailbox.sentbox.paginate(:per_page => 9, :page => params[:page])
|
9
|
-
else
|
10
|
-
@conversations = @mailbox.trash.paginate(:per_page => 9, :page => params[:page])
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
3
|
+
before_filter :get_mailbox, :get_box, :get_actor
|
14
4
|
# GET /messages/1
|
15
5
|
# GET /messages/1.xml
|
16
6
|
def show
|
17
|
-
@
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
if @box.eql? 'trash'
|
24
|
-
@receipts = @conversation.receipts(@actor).trash
|
25
|
-
else
|
26
|
-
@conversation.mark_as_read(@actor)
|
27
|
-
@receipts = @conversation.receipts(@actor).not_trash
|
7
|
+
if @message = Message.find_by_id(params[:id]) and @conversation = @message.conversation
|
8
|
+
if @conversation.is_participant?(@actor)
|
9
|
+
redirect_to conversation_path(@conversation, :box => @box, :anchor => "message_" + @message.id.to_s)
|
10
|
+
return
|
11
|
+
end
|
28
12
|
end
|
29
|
-
|
30
13
|
end
|
31
14
|
|
32
15
|
# GET /messages/new
|
@@ -34,6 +17,7 @@ class MessagesController < ApplicationController
|
|
34
17
|
def new
|
35
18
|
if params[:receiver].present?
|
36
19
|
@recipient = Actor.find_by_slug(params[:receiver])
|
20
|
+
return if @recipient.nil?
|
37
21
|
@recipient = nil if Actor.normalize(@recipient)==Actor.normalize(current_subject)
|
38
22
|
end
|
39
23
|
end
|
@@ -46,31 +30,19 @@ class MessagesController < ApplicationController
|
|
46
30
|
# POST /messages
|
47
31
|
# POST /messages.xml
|
48
32
|
def create
|
49
|
-
@conversation = Conversation.new
|
50
|
-
if params[:subject].blank?
|
51
|
-
@conversation.errors.add("subject", "can't be empty")
|
52
|
-
end
|
53
|
-
if params[:body].blank?
|
54
|
-
@conversation.errors.add("body", "can't be empty")
|
55
|
-
end
|
56
|
-
if params[:_recipients].nil? or params[:_recipients]==[]
|
57
|
-
@conversation.errors.add("recipients", "can't be empty")
|
58
|
-
end
|
59
|
-
if @conversation.errors.any?
|
60
|
-
render :action => :new
|
61
|
-
return
|
62
|
-
end
|
63
33
|
@actor = current_subject
|
64
34
|
@recipients = Array.new
|
65
|
-
params[:_recipients].
|
66
|
-
|
67
|
-
|
68
|
-
|
35
|
+
if params[:_recipients].present?
|
36
|
+
params[:_recipients].each do |recp_id|
|
37
|
+
recp = Actor.find_by_id(recp_id)
|
38
|
+
next if recp.nil?
|
39
|
+
@recipients << recp
|
40
|
+
end
|
69
41
|
end
|
70
|
-
|
71
|
-
if (
|
72
|
-
@conversation =
|
73
|
-
redirect_to
|
42
|
+
@receipt = @actor.send_message(@recipients, params[:body], params[:subject])
|
43
|
+
if (@receipt.errors.blank?)
|
44
|
+
@conversation = @receipt.conversation
|
45
|
+
redirect_to conversation_path(@conversation, :box => :sentbox)
|
74
46
|
else
|
75
47
|
render :action => :new
|
76
48
|
end
|
@@ -79,56 +51,13 @@ class MessagesController < ApplicationController
|
|
79
51
|
# PUT /messages/1
|
80
52
|
# PUT /messages/1.xml
|
81
53
|
def update
|
82
|
-
@actor = Actor.normalize(current_subject)
|
83
|
-
@conversation = Conversation.find_by_id(params[:id])
|
84
|
-
if @conversation.nil? or !@conversation.is_participant?(@actor)
|
85
|
-
redirect_to messages_path(:box => @box)
|
86
|
-
return
|
87
|
-
end
|
88
|
-
|
89
|
-
if params[:untrash].present?
|
90
|
-
@conversation.untrash(@actor)
|
91
|
-
end
|
92
|
-
|
93
|
-
if params[:reply_all].present?
|
94
|
-
if params[:body].present?
|
95
|
-
last_receipt = @conversation.receipts(@actor).last
|
96
|
-
@actor.reply_to_all(last_receipt, params[:body])
|
97
|
-
end
|
98
|
-
end
|
99
54
|
|
100
|
-
if @box.eql? 'trash'
|
101
|
-
@receipts = @conversation.receipts(@actor).trash
|
102
|
-
else
|
103
|
-
@conversation.mark_as_read(@actor)
|
104
|
-
@receipts = @conversation.receipts(@actor).not_trash
|
105
|
-
end
|
106
|
-
render :action => :show
|
107
55
|
end
|
108
56
|
|
109
57
|
# DELETE /messages/1
|
110
58
|
# DELETE /messages/1.xml
|
111
59
|
def destroy
|
112
|
-
@actor = Actor.normalize(current_subject)
|
113
|
-
@conversation = Conversation.find_by_id(params[:id])
|
114
|
-
if @conversation.nil? or !@conversation.is_participant?(@actor)
|
115
|
-
redirect_to messages_path(:box => @box)
|
116
|
-
return
|
117
|
-
end
|
118
|
-
|
119
|
-
@conversation.move_to_trash(@actor)
|
120
60
|
|
121
|
-
if params[:location].present?
|
122
|
-
case params[:location]
|
123
|
-
when 'conversation'
|
124
|
-
redirect_to messages_path(:box => :trash)
|
125
|
-
return
|
126
|
-
else
|
127
|
-
redirect_to messages_path(:box => @box)
|
128
|
-
return
|
129
|
-
end
|
130
|
-
end
|
131
|
-
redirect_to messages_path(:box => @box)
|
132
61
|
end
|
133
62
|
|
134
63
|
private
|
@@ -137,6 +66,10 @@ class MessagesController < ApplicationController
|
|
137
66
|
@mailbox = current_subject.mailbox
|
138
67
|
end
|
139
68
|
|
69
|
+
def get_actor
|
70
|
+
@actor = Actor.normalize(current_subject)
|
71
|
+
end
|
72
|
+
|
140
73
|
def get_box
|
141
74
|
if params[:box].blank? or !["inbox","sentbox","trash"].include?params[:box]
|
142
75
|
@box = "inbox"
|
@@ -15,5 +15,41 @@ class PshbController < ApplicationController
|
|
15
15
|
# requested unsubscription by someone in this node
|
16
16
|
# and delete permissions/remote actor if necessary
|
17
17
|
end
|
18
|
+
|
19
|
+
logger.debug request.body.read
|
18
20
|
end
|
19
|
-
|
21
|
+
|
22
|
+
require "net/http"
|
23
|
+
require "uri"
|
24
|
+
|
25
|
+
def pshb_subscription_request#(topic,hub,mode)
|
26
|
+
t = Thread.new do
|
27
|
+
#test
|
28
|
+
hub = 'http://138.4.7.113:4567/' # last '/' is mandatory!
|
29
|
+
topic = 'http://138.4.7.69:3000/api/user/demo/home.atom'
|
30
|
+
mode = 'subscribe'
|
31
|
+
#
|
32
|
+
uri = URI.parse(hub)
|
33
|
+
response = Net::HTTP::post_form(uri,{ 'hub.callback' => pshb_callback_url,
|
34
|
+
'hub.mode' => mode,
|
35
|
+
'hub.topic' => topic,
|
36
|
+
'hub.verify' => 'sync'})
|
37
|
+
puts response.body
|
38
|
+
#TO-DO: process 4XX response.status
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def pshb_publish#(topic,hub)
|
43
|
+
t = Thread.new do
|
44
|
+
#test params
|
45
|
+
hub = 'http://138.4.7.113:4567/' # last '/' is mandatory!
|
46
|
+
topic = 'http://138.4.7.69:3000/api/user/demo/home.atom'
|
47
|
+
#
|
48
|
+
uri = URI.parse(hub)
|
49
|
+
response = Net::HTTP::post_form(uri,{ 'hub.mode' => 'publish',
|
50
|
+
'hub.url' => topic})
|
51
|
+
#TO-DO: process 4XX response.status
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|