social_stream 0.11.6 → 0.11.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -275,9 +275,9 @@ class Activity < ActiveRecord::Base
275
275
  relations.select{ |r| r.actor_id == Actor.normalize_id(subject)}
276
276
 
277
277
  if visible_relations.present?
278
- [ :visible, visible_relations.map(&:name).join(", ") ]
278
+ [ :visible, visible_relations.map(&:name).uniq.join(", ") ]
279
279
  else
280
- [ :hidden, relations.map(&:actor).map(&:name).join(", ") ]
280
+ [ :hidden, relations.map(&:actor).map(&:name).uniq.join(", ") ]
281
281
  end
282
282
  end
283
283
 
@@ -107,6 +107,11 @@ class Contact < ActiveRecord::Base
107
107
  inverse.ties_count > 0
108
108
  end
109
109
 
110
+ def positive_replied?
111
+ inverse_id.present? &&
112
+ self.class.positive.where(:id => inverse.id).any?
113
+ end
114
+
110
115
  # The {ActivityVerb} corresponding to this {Contact}. If this contact is pending,
111
116
  # the other one was establised already, so this is going to "make-friend".
112
117
  # If it is not pending, the contact in the other way was not established, so this
@@ -135,6 +135,11 @@ class Relation < ActiveRecord::Base
135
135
  Relation.mode(sender_type, receiver_type)
136
136
  end
137
137
 
138
+ # Is this {Relation} a Positive one?
139
+ def positive?
140
+ self.class.positive_names.include?(self.class.to_s)
141
+ end
142
+
138
143
  private
139
144
 
140
145
  # Before create callback
@@ -82,6 +82,21 @@ class Tie < ActiveRecord::Base
82
82
  receiver.subject
83
83
  end
84
84
 
85
+ # The {Tie} is positive if its {Relation} is
86
+ def positive?
87
+ relation.positive?
88
+ end
89
+
90
+ # Does this {Tie} have positive {Tie ties} in the other way?
91
+ def positive_replied?
92
+ contact.positive_replied?
93
+ end
94
+
95
+ # This {Tie} is {#positive? positive} and {#positive_replied? positive replied}
96
+ def bidirectional?
97
+ positive? && positive_replied?
98
+ end
99
+
85
100
  private
86
101
 
87
102
  # before_create callback
@@ -36,7 +36,7 @@
36
36
  <%= render :partial => "devise/shared/links" %>
37
37
  </div>
38
38
  <div class="form_row center">
39
- <div class="btn_login"><%= f.submit t('action.accept').capitalize,:class=>"button" %></div>
39
+ <div class="btn_login"><%= f.submit t('action.accept').capitalize,:class=>"button storePass"%></div>
40
40
  </div>
41
41
  <% end %>
42
42
  </div>
@@ -27,7 +27,7 @@
27
27
  </div>
28
28
 
29
29
  <div class="btn_login">
30
- <%= f.submit t('action.send'), :class =>"button" %>
30
+ <%= f.submit t('action.send'), :class =>"button storePass" %>
31
31
  </div>
32
32
  <% end %>
33
33
  </div>
@@ -1,7 +1,7 @@
1
1
  <% representations = current_user.represented.unshift(current_user) - [current_subject] %>
2
2
  <% unless representations.empty? %>
3
3
  <li>
4
- <%= link_to "Switch session", "javascript:;", :class=>"session_change" %>
4
+ <%= link_to t('representation.switch'), "javascript:;", :class=>"session_change" %>
5
5
  <ul>
6
6
  <% representations.each do |representation| %>
7
7
  <li>
@@ -10,4 +10,4 @@
10
10
  <% end %>
11
11
  </ul>
12
12
  </li>
13
- <% end %>
13
+ <% end %>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
 
19
19
  <div class="login_data_block">
20
- <%= f.submit t(:sign_in), :class => 'other_blue'%>
20
+ <%= f.submit t(:sign_in), :class => 'other_blue storePass'%>
21
21
  </div>
22
22
  </div>
23
23
  <div class="options">
@@ -10,7 +10,7 @@
10
10
  <div class ="content">
11
11
  <div class="contact space_center">
12
12
  <% cs.each do |contact| %>
13
- <%= link_to(image_tag(contact.logo.url(:contact), :alt => contact.name , :size => "28x28"), contact) %>
13
+ <%= link_to(image_tag(contact.logo.url(:contact), :alt => contact.name, :title => contact.name, :size => "28x28"), contact) %>
14
14
  <% end %>
15
15
  </div>
16
16
  </div>
@@ -371,6 +371,8 @@ en:
371
371
  title: "Privacy & context"
372
372
  relation_public:
373
373
  name: "Public"
374
+ representation:
375
+ switch: "Switch session"
374
376
  required: "(*) These fields are required"
375
377
  search:
376
378
  all_results: "Search all %{subject} (%{count})"
@@ -48,7 +48,7 @@ es:
48
48
  myself:
49
49
  contacts:
50
50
  group: "Todos los integrantes"
51
- user: "Tus contacts"
51
+ user: "Tus contactos"
52
52
  outside:
53
53
  contacts:
54
54
  group: "Integrantes de %{receiver}"
@@ -137,7 +137,7 @@ es:
137
137
  confirm: "¿Borrar %{element}}?"
138
138
  devise:
139
139
  links:
140
- sign_in: "Entrar"
140
+ sign_in: "Ingresar"
141
141
  sign_up: "Registrarse"
142
142
  forgot_password: "¿Olvidaste tu contraseña?"
143
143
  confirmation_instructions: "¿No recibiste instrucciones de confirmación?"
@@ -366,6 +366,8 @@ es:
366
366
  title: "Privacidad y contexto"
367
367
  relation_public:
368
368
  name: "Público"
369
+ representation:
370
+ switch: "Cambiar sessión"
369
371
  required: "(*) Estos campos son obligatorios"
370
372
  search:
371
373
  all_subject_results: "Ver todos %{subject} (%{count})"
@@ -414,7 +416,7 @@ es:
414
416
  briefing: "Cambia tu contraseña"
415
417
  success: "Ajustes guardados con éxito"
416
418
  share: "Compartir"
417
- sign_in: "Entrar"
419
+ sign_in: "Ingresar"
418
420
  sign_out: "Salir"
419
421
  sign_up: "Registrarse"
420
422
  site:
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.9.20".freeze
3
+ VERSION = "0.9.21".freeze
4
4
  end
5
5
  end
@@ -59,6 +59,10 @@ describe Tie do
59
59
  end
60
60
 
61
61
  describe "with public relation" do
62
+ before do
63
+ @tie = Factory(:public)
64
+ end
65
+
62
66
  it "should create activity" do
63
67
  count = Activity.count
64
68
 
@@ -66,9 +70,55 @@ describe Tie do
66
70
 
67
71
  Activity.count.should eq(count + 1)
68
72
  end
73
+
74
+ it "should be positive" do
75
+ @tie.should be_positive
76
+ end
77
+
78
+ it "should not be positive replied" do
79
+ @tie.should_not be_positive_replied
80
+ end
81
+
82
+ context "with public reply" do
83
+ before do
84
+ Factory(:public, :contact => @tie.contact.inverse!)
85
+
86
+ # It should reload tie.contact again, as its inverse is now set
87
+ @tie.reload
88
+ end
89
+
90
+ it "should be positive replied" do
91
+ @tie.should be_positive_replied
92
+ end
93
+
94
+ it "should be bidirectional" do
95
+ @tie.should be_bidirectional
96
+ end
97
+ end
98
+
99
+ context "with reject reply" do
100
+ before do
101
+ Factory(:reject, :contact => @tie.contact.inverse!)
102
+
103
+ # It should reload tie.contact again, as its inverse is now set
104
+ @tie.reload
105
+ end
106
+
107
+ it "should not be positive replied" do
108
+ @tie.should_not be_positive_replied
109
+ end
110
+
111
+ it "should not be bidirectional" do
112
+ @tie.should_not be_bidirectional
113
+ end
114
+ end
69
115
  end
70
116
 
71
117
  describe "with reject relation" do
118
+ before do
119
+ @tie = Factory(:reject)
120
+ end
121
+
72
122
  it "should not create activity" do
73
123
  count = Activity.count
74
124
 
@@ -76,7 +126,44 @@ describe Tie do
76
126
 
77
127
  Activity.count.should eq(count)
78
128
  end
79
- end
80
129
 
130
+ it "should not be positive" do
131
+ @tie.should_not be_positive
132
+ end
133
+
134
+ context "with public reply" do
135
+ before do
136
+ Factory(:public, :contact => @tie.contact.inverse!)
137
+
138
+ # It should reload tie.contact again, as its inverse is now set
139
+ @tie.reload
140
+ end
141
+
142
+ it "should be positive replied" do
143
+ @tie.should be_positive_replied
144
+ end
145
+
146
+ it "should not be bidirectional" do
147
+ @tie.should_not be_bidirectional
148
+ end
149
+ end
150
+
151
+ context "with reject reply" do
152
+ before do
153
+ Factory(:reject, :contact => @tie.contact.inverse!)
154
+
155
+ # It should reload tie.contact again, as its inverse is now set
156
+ @tie.reload
157
+ end
158
+
159
+ it "should not be positive replied" do
160
+ @tie.should_not be_positive_replied
161
+ end
162
+
163
+ it "should not be bidirectional" do
164
+ @tie.should_not be_bidirectional
165
+ end
166
+ end
167
+ end
81
168
  end
82
169
 
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.0.12".freeze
3
+ VERSION = "0.0.13".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.9.19')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.21')
16
16
  s.add_runtime_dependency('conference_manager-ruby', '~> 0.0.3')
17
17
 
18
18
  # Development Gem dependencies
@@ -1,3 +1,3 @@
1
1
  module SocialStream
2
- VERSION = "0.11.6".freeze
2
+ VERSION = "0.11.7".freeze
3
3
  end
@@ -2,16 +2,7 @@
2
2
  //Store password with session storage
3
3
  ////////////////////
4
4
 
5
- function log(msg) {
6
- console.log(msg)
7
- }
8
-
9
5
  $(document).ready(function () {
10
-
11
- $('#sign_in_header').bind('click', function () {
12
- storePassword();
13
- });
14
-
15
6
  $('.storePass').bind('click', function () {
16
7
  storePassword();
17
8
  });
@@ -22,6 +13,8 @@ function storePassword() {
22
13
  if (window.sessionStorage) {
23
14
  if (($("#user_password").length==1)&&($("#user_password").val()!="")){
24
15
  sessionStorage.setItem("ss_user_pass", $('#user_password').val());
25
- }
16
+ } else if (($("#password").length==1)&&($("#password").val()!="")){
17
+ sessionStorage.setItem("ss_user_pass", $('#password').val());
18
+ }
26
19
  }
27
20
  }
@@ -3,7 +3,7 @@
3
3
  ////////////////////
4
4
 
5
5
  function log(msg) {
6
- console.log(msg)
6
+ //console.log(msg)
7
7
  }
8
8
 
9
9
 
@@ -155,6 +155,7 @@ function onMessage(msg) {
155
155
 
156
156
 
157
157
  function onPresence(presence) {
158
+ //log(presence);
158
159
  from = $(presence).attr('from');
159
160
  slug = from.split("@")[0];
160
161
  if(slug != user_slug){
@@ -240,11 +241,6 @@ function initAndPlaySound(sound){
240
241
  //Chat view jquery
241
242
  ////////////////////
242
243
 
243
- $(document).ready(function () {
244
- initialTimer = setTimeout("updateChatWindow()", 15000);
245
- initAudio();
246
- });
247
-
248
244
  function setUserFunctions(){
249
245
 
250
246
  $("div.user_presence").click(function(event, ui){
@@ -139,7 +139,7 @@ class XmppController < ApplicationController
139
139
 
140
140
 
141
141
  def chatWindow
142
- if (current_user) and (current_user.connected) and (current_user.status != 'disable') and (params[:userConnected]=="true")
142
+ if (current_user) and (current_user.status != 'disable') and (params[:userConnected]=="true")
143
143
  render :partial => 'xmpp/chat_contacts'
144
144
  else
145
145
  #User not connected or chat desactivated
@@ -160,23 +160,47 @@ class XmppController < ApplicationController
160
160
  def test
161
161
  puts "TEST"
162
162
 
163
- #XMPP DOMAIN
164
- domain = SocialStream::Presence.domain
165
- #PASSWORD
166
- password= SocialStream::Presence.password
167
- #SS Username
168
- ss_name = SocialStream::Presence.social_stream_presence_username
169
-
170
- ss_sid = ss_name + "@" + domain
171
- client = Jabber::Client.new(Jabber::JID.new(ss_sid))
172
- client.connect
173
- client.auth(password)
174
-
175
- #Sending a message
176
- msg = Jabber::Message::new(ss_sid, "Message&order")
177
- msg.type=:chat
178
- client.send(msg)
179
- client.close()
163
+ # Thread.start{
164
+
165
+ # #XMPP DOMAIN
166
+ # domain = SocialStream::Presence.domain
167
+ # #PASSWORD
168
+ # password= SocialStream::Presence.password
169
+ # #SS Username
170
+ # ss_name = SocialStream::Presence.social_stream_presence_username
171
+ # ss_sid = ss_name + "@" + domain
172
+ #
173
+ # client = Jabber::Client.new(Jabber::JID.new(ss_sid))
174
+ # client.connect
175
+ # client.auth(password)
176
+ #
177
+ # #Remove all rosters
178
+ # msg = Jabber::Message::new(ss_sid, "SynchronizeRosters")
179
+ # msg.type=:chat
180
+ # client.send(msg)
181
+ #
182
+ #
183
+ # #Write rosters
184
+ # users = User.all
185
+ # checkedUsers = []
186
+ #
187
+ # users.each do |user|
188
+ # checkedUsers << user.slug
189
+ # contacts = user.contact_actors(:type=>:user)
190
+ # contacts.each do |contact|
191
+ # unless checkedUsers.include?(contact.slug)
192
+ # user_sid = user.slug + "@" + domain
193
+ # buddy_sid = contact.slug + "@" + domain
194
+ # msg = Jabber::Message::new(ss_sid, "SetRosterForBidirectionalTie&" + user_sid + "&" + buddy_sid + "&" + user.name + "&" + contact.name)
195
+ # msg.type=:chat
196
+ # client.send(msg)
197
+ # end
198
+ # end
199
+ # end
200
+ #
201
+ # client.close()
202
+ # }
203
+
180
204
  end
181
205
 
182
206
 
@@ -50,6 +50,8 @@
50
50
  if (connectToServer(null)==false){
51
51
  refreshChatWindow();
52
52
  }
53
+ initialTimer = setTimeout("updateChatWindow()", 15000);
54
+ initAudio();
53
55
  });
54
56
 
55
57
  </script>
@@ -28,27 +28,32 @@ module SocialStream
28
28
  password= SocialStream::Presence.password
29
29
  #SS Username
30
30
  ss_name = SocialStream::Presence.social_stream_presence_username
31
+ ss_sid = ss_name + "@" + domain
31
32
 
32
33
  user_sid = self.sender.slug + "@" + domain
34
+ user_name = self.sender.name
33
35
  buddy_sid = self.receiver.slug + "@" + domain
34
36
  buddy_name = self.receiver.name
35
-
36
- #Check Subscription_type
37
- if isBidirectionalTie
38
- sType = "both"
39
- else
40
- sType = "from"
41
- end
37
+
42
38
 
43
39
  begin
44
- ss_sid = ss_name + "@" + domain
45
40
  client = Jabber::Client.new(Jabber::JID.new(ss_sid))
46
41
  client.connect
47
42
  client.auth(password)
48
43
 
49
- #Sending a message
50
- #AddItemToRoster[UserSID,BuddySID,BuddyName,Subscription_type]
51
- msg = Jabber::Message::new(ss_sid, "AddItemToRoster&" + user_sid + "&" + buddy_sid + "&" + buddy_name + "&" + sType)
44
+ #Check if is a positive and replied tie
45
+ if self.bidirectional?
46
+ #SetRosterForBidirectionalTie[UserASID,UserBSID,UserAName,UserBName]
47
+ msg = Jabber::Message::new(ss_sid, "SetRosterForBidirectionalTie&" + user_sid + "&" + buddy_sid + "&" + buddy_name + "&" + user_name)
48
+ elsif self.positive?
49
+ #Case: Possitive tie unidirectional
50
+ sType = "from"
51
+ #AddItemToRoster[UserSID,BuddySID,BuddyName,Subscription_type]
52
+ msg = Jabber::Message::new(ss_sid, "AddItemToRoster&" + user_sid + "&" + buddy_sid + "&" + buddy_name + "&" + sType)
53
+ else
54
+ return
55
+ end
56
+
52
57
  msg.type=:chat
53
58
  client.send(msg)
54
59
  client.close()
@@ -64,10 +69,6 @@ module SocialStream
64
69
 
65
70
  end
66
71
 
67
- def isBidirectionalTie
68
- return true
69
- end
70
-
71
72
  end
72
73
  end
73
74
  end
@@ -0,0 +1,63 @@
1
+ namespace :presence do
2
+ desc 'Synchronize the Xmpp Server database with the Social Stream database'
3
+ task :synchronize => [ 'presence:synchronize:connections', 'presence:synchronize:rosters' ]
4
+
5
+ namespace :synchronize do
6
+
7
+
8
+ desc "Synchronize user presence."
9
+ task :connections => :environment do
10
+ puts "Starting presence:synchronize:connections"
11
+ puts "Synchronization complete"
12
+ end
13
+
14
+ desc "Remove all rosters and populate rosters from Social Stream data."
15
+ task :rosters => :environment do
16
+ puts "Starting presence:synchronize:rosters"
17
+
18
+ #XMPP DOMAIN
19
+ domain = SocialStream::Presence.domain
20
+ #PASSWORD
21
+ password= SocialStream::Presence.password
22
+ #SS Username
23
+ ss_name = SocialStream::Presence.social_stream_presence_username
24
+ ss_sid = ss_name + "@" + domain
25
+
26
+ puts "Connecting to Xmpp Server"
27
+ client = Jabber::Client.new(Jabber::JID.new(ss_sid))
28
+ client.connect
29
+ client.auth(password)
30
+ puts "Connected to Xmpp Server"
31
+
32
+ puts "Remove all rosters"
33
+ msg = Jabber::Message::new(ss_sid, "SynchronizeRosters")
34
+ msg.type=:chat
35
+ client.send(msg)
36
+
37
+
38
+ puts "Populate rosters"
39
+ users = User.all
40
+ checkedUsers = []
41
+
42
+ users.each do |user|
43
+ checkedUsers << user.slug
44
+ contacts = user.contact_actors(:type=>:user)
45
+ contacts.each do |contact|
46
+ unless checkedUsers.include?(contact.slug)
47
+ user_sid = user.slug + "@" + domain
48
+ buddy_sid = contact.slug + "@" + domain
49
+ msg = Jabber::Message::new(ss_sid, "SetRosterForBidirectionalTie&" + user_sid + "&" + buddy_sid + "&" + user.name + "&" + contact.name)
50
+ msg.type=:chat
51
+ client.send(msg)
52
+ end
53
+ end
54
+ end
55
+
56
+ puts "Synchronization complete"
57
+ puts "Closing connection"
58
+ client.close()
59
+ puts "Connection closing"
60
+
61
+ end
62
+ end
63
+ end
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files`.split("\n")
12
12
 
13
13
  # Gem dependencies
14
- s.add_runtime_dependency('social_stream-base', '~> 0.9.20')
14
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.21')
15
15
  s.add_runtime_dependency('social_stream-documents', '~> 0.3.2')
16
- s.add_runtime_dependency('social_stream-events', '~> 0.0.12')
16
+ s.add_runtime_dependency('social_stream-events', '~> 0.0.13')
17
17
 
18
18
  # Development Gem dependencies
19
19
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 6
10
- version: 0.11.6
9
+ - 7
10
+ version: 0.11.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - GING - DIT - UPM
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-14 00:00:00 +02:00
19
+ date: 2011-10-17 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 19
30
+ hash: 17
31
31
  segments:
32
32
  - 0
33
33
  - 9
34
- - 20
35
- version: 0.9.20
34
+ - 21
35
+ version: 0.9.21
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -59,12 +59,12 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- hash: 7
62
+ hash: 5
63
63
  segments:
64
64
  - 0
65
65
  - 0
66
- - 12
67
- version: 0.0.12
66
+ - 13
67
+ version: 0.0.13
68
68
  type: :runtime
69
69
  version_requirements: *id003
70
70
  - !ruby/object:Gem::Dependency
@@ -1169,6 +1169,7 @@ files:
1169
1169
  - presence/lib/social_stream/presence/config.rb
1170
1170
  - presence/lib/social_stream/presence/engine.rb
1171
1171
  - presence/lib/social_stream/presence/models/buddy_manager.rb
1172
+ - presence/lib/tasks/presence/synchronize.rake
1172
1173
  - presence/social_stream-presence.gemspec
1173
1174
  - presence/spec/demo/.gitignore
1174
1175
  - presence/spec/demo/.rspec