social_stream 0.11.8 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/base/app/assets/images/btn/download.png +0 -0
- data/base/app/assets/javascripts/activities.js.erb +1 -1
- data/base/app/assets/javascripts/social_stream-base.js +2 -0
- data/base/app/assets/stylesheets/social_stream-base.css +2 -0
- data/base/app/views/avatars/index.html.erb +0 -13
- data/base/app/views/comments/create.js.erb +3 -0
- data/base/app/views/toolbar/_home.html.erb +1 -1
- data/base/config/locales/en.yml +1 -0
- data/base/config/locales/es.yml +1 -0
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/lib/social_stream/controllers/helpers.rb +6 -0
- data/base/lib/social_stream/migrations/base.rb +12 -9
- data/base/lib/social_stream/migrations/components.rb +1 -1
- data/base/social_stream-base.gemspec +1 -1
- data/documents/Rakefile +3 -13
- data/documents/app/assets/javascripts/documents.js.erb +21 -32
- data/documents/app/assets/javascripts/social_stream-documents.js +2 -1
- data/documents/app/assets/stylesheets/{documents.css → documents.css.scss} +32 -6
- data/documents/app/assets/stylesheets/show.css.scss +75 -0
- data/documents/app/assets/stylesheets/social_stream-documents.css +2 -1
- data/documents/app/controllers/audios_controller.rb +0 -14
- data/documents/app/controllers/common_documents_controller.rb +6 -3
- data/documents/app/controllers/documents_controller.rb +9 -3
- data/documents/app/controllers/pictures_controller.rb +0 -1
- data/documents/app/controllers/videos_controller.rb +0 -15
- data/documents/app/helpers/documents_helper.rb +11 -7
- data/documents/app/models/audio.rb +1 -1
- data/documents/app/models/document.rb +9 -5
- data/documents/app/models/picture.rb +1 -1
- data/documents/app/models/video.rb +8 -6
- data/documents/app/views/audios/_audio.html.erb +2 -2
- data/documents/app/views/audios/_audio_processed.html.erb +4 -4
- data/documents/app/views/audios/_audio_show.html.erb +62 -0
- data/documents/app/views/audios/index.html.erb +1 -1
- data/documents/app/views/audios/show.html.erb +2 -2
- data/documents/app/views/common_documents/_document_info.html.erb +34 -0
- data/documents/app/views/common_documents/_index.html.erb +49 -0
- data/documents/app/views/common_documents/_show.html.erb +36 -0
- data/documents/app/views/documents/_document.html.erb +2 -6
- data/documents/app/views/documents/_document_show.html.erb +7 -0
- data/documents/app/views/documents/index.html.erb +1 -1
- data/documents/app/views/documents/show.html.erb +2 -2
- data/documents/app/views/pictures/_picture.html.erb +13 -12
- data/documents/app/views/pictures/_picture_show.html.erb +26 -0
- data/documents/app/views/pictures/index.html.erb +1 -1
- data/documents/app/views/pictures/show.html.erb +2 -2
- data/documents/app/views/videos/_video.html.erb +2 -2
- data/documents/app/views/videos/_video_processed.html.erb +4 -3
- data/documents/app/views/videos/_video_show.html.erb +64 -0
- data/documents/app/views/videos/index.html.erb +1 -1
- data/documents/app/views/videos/show.html.erb +2 -2
- data/documents/config/locales/en.yml +19 -1
- data/documents/config/locales/es.yml +18 -0
- data/documents/lib/social_stream/documents/engine.rb +2 -0
- data/documents/lib/social_stream/documents/version.rb +1 -1
- data/documents/social_stream-documents.gemspec +1 -1
- data/documents/spec/controllers/documents_controller_spec.rb +40 -2
- data/documents/spec/controllers/pictures_controller_spec.rb +4 -4
- data/documents/spec/dummy/config/environments/development.rb +0 -1
- data/documents/spec/dummy/config/environments/test.rb +2 -0
- data/lib/social_stream/release.rb +26 -4
- data/lib/social_stream/version.rb +1 -1
- data/presence/app/assets/javascripts/xmpp_client.js +0 -6
- data/presence/app/controllers/xmpp_controller.rb +46 -102
- data/presence/app/views/xmpp/_chat.html.erb +1 -2
- data/presence/ejabberd/conf/{ejabberd.cfg → ejabberd_example.cfg} +3 -7
- data/presence/ejabberd/conf/ssconfig_example.cfg +32 -0
- data/presence/ejabberd/ejabberd_scripts/authentication_script +7 -3
- data/presence/ejabberd/ejabberd_scripts/{compile_module → development_scripts/compile_module} +0 -0
- data/presence/ejabberd/ejabberd_scripts/{generate_random_password → development_scripts/generate_random_password} +0 -0
- data/presence/ejabberd/ejabberd_scripts/{kill_authentication_script.sh → development_scripts/kill_authentication_script.sh} +0 -0
- data/presence/ejabberd/ejabberd_scripts/{reset_logs.sh → development_scripts/reset_logs.sh} +0 -2
- data/presence/ejabberd/ejabberd_scripts/{show_config.sh → development_scripts/show_config.sh} +3 -0
- data/presence/ejabberd/ejabberd_scripts/{start_ejabberd.sh → development_scripts/start_ejabberd.sh} +0 -0
- data/presence/ejabberd/ejabberd_scripts/{stop_ejabberd.sh → development_scripts/stop_ejabberd.sh} +0 -0
- data/presence/ejabberd/ejabberd_scripts/emanagement +18 -14
- data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +11 -7
- data/presence/lib/generators/social_stream/presence/templates/initializer.rb +14 -4
- data/presence/lib/social_stream/migrations/presence.rb +0 -1
- data/presence/lib/social_stream/presence/engine.rb +1 -48
- data/presence/lib/social_stream/presence/models/buddy_manager.rb +17 -44
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/presence/lib/social_stream/presence/xmpp_server_order.rb +181 -0
- data/presence/lib/social_stream-presence.rb +12 -2
- data/presence/lib/tasks/presence/synchronize.rake +6 -47
- data/social_stream.gemspec +2 -2
- metadata +32 -28
- data/base/lib/social_stream/migrations/finder.rb +0 -20
- data/documents/app/views/common-documents/_index.html.erb +0 -45
- data/documents/app/views/toolbar/_uploads_menu.html.erb +0 -21
- data/presence/ejabberd/conf/ejabberdctl.cfg +0 -154
- data/presence/ejabberd/conf/inetrc +0 -3
- data/presence/ejabberd/conf/ssconfig.cfg +0 -32
- data/presence/ejabberd/ejabberd_scripts/authentication_script_org +0 -114
@@ -5,19 +5,41 @@ module SocialStream
|
|
5
5
|
# First of all, update gems
|
6
6
|
system "bundle"
|
7
7
|
|
8
|
-
|
8
|
+
parse_args(args)
|
9
9
|
|
10
|
-
|
10
|
+
all.each(&:bump_version)
|
11
|
+
|
12
|
+
all.each(&:update_dependencies)
|
13
|
+
|
14
|
+
system("git commit #{ all.map(&:commit_files).join(" ") } -m #{ @global.version }") ||
|
15
|
+
raise(RuntimeError.new)
|
16
|
+
|
17
|
+
all.each(&:rake_release)
|
18
|
+
end
|
19
|
+
|
20
|
+
def dependencies
|
21
|
+
@dependencies ||=
|
22
|
+
Global::Release.new.dependencies
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse_args args
|
26
|
+
@components = []
|
27
|
+
|
28
|
+
args.each do |a|
|
11
29
|
name, version = a.split(":")
|
12
30
|
|
13
31
|
if dependencies.include?(name)
|
14
|
-
Component::Release.new(name, version)
|
32
|
+
@components << Component::Release.new(name, version)
|
15
33
|
else
|
16
34
|
@target = name
|
17
35
|
end
|
18
36
|
end
|
19
37
|
|
20
|
-
Global::Release.new(@target)
|
38
|
+
@global = Global::Release.new(@target)
|
39
|
+
end
|
40
|
+
|
41
|
+
def all
|
42
|
+
@components + [ @global ]
|
21
43
|
end
|
22
44
|
end
|
23
45
|
end
|
@@ -241,12 +241,6 @@ function initAndPlaySound(sound){
|
|
241
241
|
//Chat view jquery
|
242
242
|
////////////////////
|
243
243
|
|
244
|
-
function initDelegates(){
|
245
|
-
$('.user_presence').delegate( '.user_presence a[title]', 'hover', function(){
|
246
|
-
e.preventDefault();
|
247
|
-
});
|
248
|
-
}
|
249
|
-
|
250
244
|
function setUserFunctions(){
|
251
245
|
|
252
246
|
$("div.user_presence").click(function(event, ui){
|
@@ -1,9 +1,3 @@
|
|
1
|
-
require 'xmpp4r'
|
2
|
-
require 'xmpp4r/muc'
|
3
|
-
require 'xmpp4r/roster'
|
4
|
-
require 'xmpp4r/client'
|
5
|
-
require 'xmpp4r/message'
|
6
|
-
|
7
1
|
class XmppController < ApplicationController
|
8
2
|
|
9
3
|
#Mapping XMPP Standar Status to Social Stream Chat Status
|
@@ -19,24 +13,27 @@ class XmppController < ApplicationController
|
|
19
13
|
|
20
14
|
|
21
15
|
#API METHODS
|
22
|
-
|
23
|
-
def
|
16
|
+
|
17
|
+
def setConnection
|
24
18
|
unless authorization
|
25
19
|
render :text => "Authorization error"
|
26
20
|
return
|
27
21
|
end
|
28
22
|
|
29
|
-
|
23
|
+
user = User.find_by_slug(params[:name])
|
30
24
|
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
if user && !user.connected
|
26
|
+
user.connected = true
|
27
|
+
user.status = "available"
|
28
|
+
user.save!
|
29
|
+
render :text => "Ok"
|
30
|
+
return
|
34
31
|
end
|
35
32
|
|
36
|
-
render :text => "
|
33
|
+
render :text => "Error"
|
37
34
|
end
|
38
|
-
|
39
|
-
|
35
|
+
|
36
|
+
|
40
37
|
def unsetConecction
|
41
38
|
unless authorization
|
42
39
|
render :text => "Authorization error"
|
@@ -52,87 +49,78 @@ class XmppController < ApplicationController
|
|
52
49
|
return
|
53
50
|
end
|
54
51
|
|
55
|
-
render :text => "
|
52
|
+
render :text => "User not connected"
|
56
53
|
end
|
57
54
|
|
58
55
|
|
59
|
-
def
|
56
|
+
def setPresence
|
60
57
|
unless authorization
|
61
58
|
render :text => "Authorization error"
|
62
59
|
return
|
63
60
|
end
|
64
61
|
|
65
62
|
user = User.find_by_slug(params[:name])
|
63
|
+
status = params[:status]
|
66
64
|
|
67
|
-
if user
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
if setStatus(user,status)
|
66
|
+
if user && !user.connected
|
67
|
+
user.connected = true
|
68
|
+
user.save!
|
69
|
+
end
|
70
|
+
render :text => 'Status changed'
|
71
|
+
else
|
72
|
+
render :text => 'Status not changed'
|
73
73
|
end
|
74
74
|
|
75
|
-
render :text => "Error"
|
76
75
|
end
|
77
76
|
|
78
77
|
|
79
|
-
def
|
78
|
+
def unsetPresence
|
80
79
|
unless authorization
|
81
80
|
render :text => "Authorization error"
|
82
81
|
return
|
83
82
|
end
|
84
|
-
|
85
|
-
#Actual connected users
|
86
|
-
user_slugs = params[:name]
|
87
|
-
|
88
|
-
#Check connected users
|
89
|
-
users = User.find_all_by_connected(true)
|
90
83
|
|
91
|
-
|
92
|
-
if user_slugs.include?(user.slug) == false
|
93
|
-
user.connected = false
|
94
|
-
user.save!
|
95
|
-
end
|
96
|
-
end
|
84
|
+
user = User.find_by_slug(params[:name])
|
97
85
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
86
|
+
if user && user.connected
|
87
|
+
user.connected = false
|
88
|
+
user.save!
|
89
|
+
render :text => "Ok"
|
90
|
+
return
|
104
91
|
end
|
105
92
|
|
106
|
-
render :text => "
|
93
|
+
render :text => "User not connected"
|
107
94
|
end
|
108
95
|
|
109
96
|
|
110
|
-
def
|
97
|
+
def resetConnection
|
111
98
|
unless authorization
|
112
99
|
render :text => "Authorization error"
|
113
100
|
return
|
114
101
|
end
|
115
102
|
|
116
|
-
|
117
|
-
status = params[:status]
|
118
|
-
|
119
|
-
if setStatus(user,status)
|
120
|
-
render :text => 'Status changed'
|
121
|
-
else
|
122
|
-
render :text => 'Status not changed'
|
123
|
-
end
|
103
|
+
SocialStream::Presence::XmppServerOrder::reset_presence
|
124
104
|
|
105
|
+
render :text => "Ok"
|
125
106
|
end
|
126
107
|
|
127
108
|
|
128
|
-
def
|
109
|
+
def synchronizePresence
|
129
110
|
unless authorization
|
130
111
|
render :text => "Authorization error"
|
131
112
|
return
|
132
|
-
end
|
133
|
-
|
113
|
+
end
|
114
|
+
|
115
|
+
#Actual connected users
|
116
|
+
user_slugs = params[:name]
|
117
|
+
|
118
|
+
SocialStream::Presence::XmppServerOrder::synchronize_presence_for_slugs(user_slugs)
|
119
|
+
|
120
|
+
render :text => "ok"
|
134
121
|
end
|
135
122
|
|
123
|
+
|
136
124
|
def authorization
|
137
125
|
return params[:password] == SocialStream::Presence.xmpp_server_password
|
138
126
|
end
|
@@ -146,8 +134,7 @@ class XmppController < ApplicationController
|
|
146
134
|
render :partial => 'xmpp/chat_off'
|
147
135
|
end
|
148
136
|
end
|
149
|
-
|
150
|
-
|
137
|
+
|
151
138
|
|
152
139
|
|
153
140
|
|
@@ -158,53 +145,10 @@ class XmppController < ApplicationController
|
|
158
145
|
end
|
159
146
|
|
160
147
|
def test
|
161
|
-
puts "TEST"
|
162
|
-
|
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
|
-
|
148
|
+
#puts "TEST"
|
204
149
|
end
|
205
150
|
|
206
151
|
|
207
|
-
|
208
152
|
private
|
209
153
|
|
210
154
|
def setStatus(user,status)
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<script type="text/javascript">
|
15
15
|
|
16
16
|
//Global variables
|
17
|
-
var BOSH_SERVICE = '<%=SocialStream::Presence.bosh_service%>';
|
17
|
+
var BOSH_SERVICE = '<%= SocialStream::Presence.bosh_service || root_url + "http-bind/" %>';
|
18
18
|
var domain = '<%=SocialStream::Presence.domain%>';
|
19
19
|
var user_name = '<%=current_user.name%>';
|
20
20
|
var user_slug = '<%=current_user.slug%>';
|
@@ -52,7 +52,6 @@
|
|
52
52
|
}
|
53
53
|
initialTimer = setTimeout("updateChatWindow()", 15000);
|
54
54
|
initAudio();
|
55
|
-
initDelegates();
|
56
55
|
});
|
57
56
|
|
58
57
|
</script>
|
@@ -88,7 +88,7 @@
|
|
88
88
|
%% You can define one or several, for example:
|
89
89
|
%% {hosts, ["example.net", "example.com", "example.org"]}.
|
90
90
|
%%
|
91
|
-
{hosts, ["
|
91
|
+
{hosts, ["example.com"]}.
|
92
92
|
|
93
93
|
%%
|
94
94
|
%% route_subdomains: Delegate subdomains to other XMPP servers.
|
@@ -115,8 +115,7 @@
|
|
115
115
|
%% certificate, specify the full path to the
|
116
116
|
%% file and uncomment this line:
|
117
117
|
%%
|
118
|
-
%%{certfile, "/path/to/
|
119
|
-
{certfile, "/etc/ejabberd/server.pem"}, starttls,
|
118
|
+
%%{certfile, "/path/to/your_ssl_certificate.pem"}, starttls,
|
120
119
|
|
121
120
|
{access, c2s},
|
122
121
|
{shaper, c2s_shaper},
|
@@ -235,13 +234,10 @@
|
|
235
234
|
%% Exauth Response Timeout is a extauth module constant and its value is 60 seconds.
|
236
235
|
%%
|
237
236
|
{auth_method, external}.
|
238
|
-
{extauth_program, "/
|
237
|
+
{extauth_program, "/scripts_path/authentication_script"}.
|
239
238
|
{extauth_instances, 3}.
|
240
239
|
|
241
240
|
|
242
|
-
%%{auth_method, external}.
|
243
|
-
%%{extauth_program, "/home/aldo/ejabberd-2.1.8_scripts/authentication_script"}.
|
244
|
-
|
245
241
|
%%
|
246
242
|
%% Authentication using ODBC
|
247
243
|
%% Remember to setup a database in the next section.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#Social Stream Presence: ejabberd config
|
2
|
+
|
3
|
+
#Ejabberd node server domain
|
4
|
+
server_domain=domain.example.com
|
5
|
+
|
6
|
+
#Scripts Path
|
7
|
+
scripts_path=/my_scripts_path
|
8
|
+
|
9
|
+
#Source path: uncomment to compile ejabberd social stream module
|
10
|
+
#source_path=/.../ejabberd_source/src
|
11
|
+
|
12
|
+
#It is also necessary to modify the file: /etc/ejabberd/ejabberd.cfg
|
13
|
+
#%%{auth_method, external}.
|
14
|
+
#%%{extauth_program, "scripts_path/authentication_script"}.
|
15
|
+
|
16
|
+
#API REST
|
17
|
+
auth_api=http://localhost/users/sign_in
|
18
|
+
set_connection_api=http://localhost/xmpp/setConnection
|
19
|
+
unset_connection_api=http://localhost/xmpp/unsetConnection
|
20
|
+
reset_connection_api=http://localhost/xmpp/resetConnection
|
21
|
+
synchronize_presence_api=http://localhost/xmpp/synchronizePresence
|
22
|
+
set_presence_api=http://localhost/xmpp/setPresence
|
23
|
+
unset_presence_api=http://localhost/xmpp/unsetPresence
|
24
|
+
|
25
|
+
#Social Stream Login
|
26
|
+
ss_login=social_stream-presence
|
27
|
+
|
28
|
+
#Social Stream PASSWORD
|
29
|
+
ss_password=password
|
30
|
+
|
31
|
+
#Ejabberd Server Password
|
32
|
+
ejabberd_password=password
|
@@ -45,8 +45,12 @@ def auth(username, password)
|
|
45
45
|
#end
|
46
46
|
|
47
47
|
#Social Stream password
|
48
|
-
if username == $sslogin
|
49
|
-
|
48
|
+
if username == $sslogin
|
49
|
+
if password == $sspass
|
50
|
+
return true
|
51
|
+
else
|
52
|
+
return false
|
53
|
+
end
|
50
54
|
end
|
51
55
|
|
52
56
|
begin
|
@@ -87,7 +91,7 @@ loop do
|
|
87
91
|
|
88
92
|
when "auth"
|
89
93
|
$logger.info "#{Process.pid}: Authenticating #{data[0]}@#{data[1]}"
|
90
|
-
|
94
|
+
#$logger.info "#{Process.pid}: With password #{data[2]}"
|
91
95
|
#password = data[2]
|
92
96
|
|
93
97
|
#Authorization condition for LOGIN
|
data/presence/ejabberd/ejabberd_scripts/{compile_module → development_scripts/compile_module}
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -3,14 +3,12 @@
|
|
3
3
|
echo "Starting Reset logs"
|
4
4
|
|
5
5
|
rm /var/log/ejabberd/auth.log
|
6
|
-
rm /var/log/ejabberd/auth_error.log
|
7
6
|
rm /var/log/ejabberd/ejabberd.log
|
8
7
|
rm /var/log/ejabberd/erlang.log
|
9
8
|
rm /var/log/ejabberd/scripts.log
|
10
9
|
rm /var/log/ejabberd/erl_crash_*
|
11
10
|
|
12
11
|
touch /var/log/ejabberd/auth.log
|
13
|
-
touch /var/log/ejabberd/auth_error.log
|
14
12
|
touch /var/log/ejabberd/ejabberd.log
|
15
13
|
touch /var/log/ejabberd/erlang.log
|
16
14
|
touch /var/log/ejabberd/scripts.log
|
data/presence/ejabberd/ejabberd_scripts/{show_config.sh → development_scripts/show_config.sh}
RENAMED
@@ -19,12 +19,15 @@ puts "############### Ejabberd Configuration ###############"
|
|
19
19
|
puts "Config file for Social Stream Presence: /etc/ejabberd/ssconfig.cfg"
|
20
20
|
puts "Scripts Path: #{getOption("scripts_path=")}"
|
21
21
|
puts "mod_sspresence Path: #{getOption("source_path=")}"
|
22
|
+
puts "Server domain: #{getOption("server_domain=")}"
|
22
23
|
puts "API REST URLs"
|
23
24
|
puts "Authentication: #{getOption("auth_api=")}"
|
24
25
|
puts "onRegisterConnection: #{getOption("set_connection_api=")}"
|
25
26
|
puts "onRemoveConnection: #{getOption("unset_connection_api=")}"
|
26
27
|
puts "onPresence: #{getOption("set_presence_api=")}"
|
27
28
|
puts "onUnsetPresence: #{getOption("unset_presence_api=")}"
|
29
|
+
puts "ResetConnection: #{getOption("reset_connection_api=")}"
|
30
|
+
puts "SynchronizePresence: #{getOption("synchronize_presence_api=")}"
|
28
31
|
puts "Social Stream Presence logs in var/log/ejabberd/"
|
29
32
|
puts "######################################################"
|
30
33
|
puts ""
|
data/presence/ejabberd/ejabberd_scripts/{start_ejabberd.sh → development_scripts/start_ejabberd.sh}
RENAMED
File without changes
|
data/presence/ejabberd/ejabberd_scripts/{stop_ejabberd.sh → development_scripts/stop_ejabberd.sh}
RENAMED
File without changes
|
@@ -39,7 +39,7 @@ PARAMS_FOR_COMMANDS = {
|
|
39
39
|
'addBuddyToRoster' => 5,
|
40
40
|
'removeRoster' => 1,
|
41
41
|
'getBuddysFromRoster' => 1,
|
42
|
-
'setBidireccionalBuddys' =>
|
42
|
+
'setBidireccionalBuddys' => 6,
|
43
43
|
'help' => 0,
|
44
44
|
'getUserResource' => 1,
|
45
45
|
'sendMessageToUser' => 3,
|
@@ -52,10 +52,10 @@ PARAMS_FOR_COMMANDS = {
|
|
52
52
|
SYNTAX_FOR_COMMANDS = {
|
53
53
|
'getRoster' => "getRoster username",
|
54
54
|
'removeBuddyFromRoster' => "removeBuddyFromRoster username buddy",
|
55
|
-
'addBuddyToRoster' => "addBuddyToRoster
|
55
|
+
'addBuddyToRoster' => "addBuddyToRoster userSid buddySid buddyNick buddyGroup subscription_type",
|
56
56
|
'removeRoster' => "removeRoster username",
|
57
57
|
'getBuddysFromRoster' => "getBuddysFromRoster roster",
|
58
|
-
'setBidireccionalBuddys' => "setBidireccionalBuddys
|
58
|
+
'setBidireccionalBuddys' => "setBidireccionalBuddys userASid userBSid userANick userBNick groupForA groupForB",
|
59
59
|
'getUserResource' => "getUserResource username",
|
60
60
|
'sendMessageToUser' => "sendMessageToUser from_name to_name msg",
|
61
61
|
'sendPresence' => 'sendPresence username show',
|
@@ -88,11 +88,6 @@ def removeBuddyFromRoster(username,buddy)
|
|
88
88
|
%x[#{command}];
|
89
89
|
end
|
90
90
|
|
91
|
-
def addBuddyToRoster(username,buddy,buddyNick,buddyGroup,subscription_type)
|
92
|
-
command = "ejabberdctl add-rosteritem " + username + " " + $domain + " " + buddy + " " + $domain + " \\'" + buddyNick + "\\' " + buddyGroup + " " + subscription_type
|
93
|
-
%x[#{command}];
|
94
|
-
end
|
95
|
-
|
96
91
|
def removeRoster(username)
|
97
92
|
user_roster = getRoster(username);
|
98
93
|
user_buddys = getBuddysFromRoster(user_roster);
|
@@ -117,15 +112,22 @@ def getBuddysFromRoster(roster)
|
|
117
112
|
buddys
|
118
113
|
end
|
119
114
|
|
120
|
-
def setBidireccionalBuddys(
|
121
|
-
|
122
|
-
addBuddyToRoster(
|
123
|
-
addBuddyToRoster(usernameB,usernameA,nickA,"SocialStream","both")
|
124
|
-
sendPresence(usernameA,"chat")
|
125
|
-
sendPresence(usernameB,"chat")
|
115
|
+
def setBidireccionalBuddys(userASid,userBSid,userANick,userBNick,groupForA,groupForB)
|
116
|
+
addBuddyToRoster(userASid,userBSid,userBNick,groupForB,"both")
|
117
|
+
addBuddyToRoster(userBSid,userASid,userANick,groupForA,"both")
|
126
118
|
return "Done"
|
127
119
|
end
|
128
120
|
|
121
|
+
def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
|
122
|
+
user = userSid.split("@")[0]
|
123
|
+
buddy = buddySid.split("@")[0]
|
124
|
+
userDomain = userSid.split("@")[1]
|
125
|
+
buddyDomain = buddySid.split("@")[1]
|
126
|
+
command = "ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " + subscription_type
|
127
|
+
puts command
|
128
|
+
%x[#{command}];
|
129
|
+
end
|
130
|
+
|
129
131
|
def sendStanzaUserMessage(username,msg)
|
130
132
|
resource = getUserResource(username);
|
131
133
|
stanza = "\\<\\'message\\'\\>\\<\\'body\\'\\>\\'" + msg + "\\'\\<\\'/body\\'\\>\\<\\'/message\\'\\>"
|
@@ -226,6 +228,8 @@ begin
|
|
226
228
|
puts send(ARGV[0],ARGV[1],ARGV[2],ARGV[3],ARGV[4])
|
227
229
|
when 6
|
228
230
|
puts send(ARGV[0],ARGV[1],ARGV[2],ARGV[3],ARGV[4],ARGV[5])
|
231
|
+
when 7
|
232
|
+
puts send(ARGV[0],ARGV[1],ARGV[2],ARGV[3],ARGV[4],ARGV[5],ARGV[6])
|
229
233
|
else
|
230
234
|
puts send(ARGV[0],ARGV)
|
231
235
|
end
|
Binary file
|
@@ -13,8 +13,8 @@ start(Host, _Opts) ->
|
|
13
13
|
ejabberd_hooks:add(set_presence_hook, Host, ?MODULE, on_presence, 50),
|
14
14
|
ejabberd_hooks:add(unset_presence_hook, Host, ?MODULE, on_unset_presence, 50),
|
15
15
|
ejabberd_hooks:add(user_send_packet, Host, ?MODULE, on_packet_send, 50),
|
16
|
-
%
|
17
|
-
|
16
|
+
%Reset connected users when module sspresence starts.
|
17
|
+
reset_connections(),
|
18
18
|
ok.
|
19
19
|
|
20
20
|
stop(Host) ->
|
@@ -169,7 +169,11 @@ execute(Message) ->
|
|
169
169
|
%frank-williamson@trapo adds demo@trapo to its roster with subscription from, in the group SocialStream with the name Nickname
|
170
170
|
%%
|
171
171
|
addItemToRoster(UserSlug,UserDomain,BuddySlug,BuddyDomain,ContactName,Group,Subscription_type) ->
|
172
|
-
Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " \\'", ContactName , "\\' ", Group , " ", Subscription_type]),
|
172
|
+
%%Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " \\'", ContactName , "\\' ", Group , " ", Subscription_type]),
|
173
|
+
%%Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " \'", ContactName , "\' ", Group , " ", Subscription_type]),
|
174
|
+
|
175
|
+
[UserName|_R] = string:tokens(ContactName, " "),
|
176
|
+
Command = lists:concat(["ejabberdctl add_rosteritem ", UserSlug , " ", UserDomain, " ", BuddySlug, " ", BuddyDomain , " ", UserName , " ", Group , " ", Subscription_type]),
|
173
177
|
os:cmd(Command),
|
174
178
|
?INFO_MSG("Execute command: ~p", [Command]),
|
175
179
|
ok.
|
@@ -248,10 +252,10 @@ ok.
|
|
248
252
|
|
249
253
|
|
250
254
|
%Reset all connections
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
+
reset_connections() ->
|
256
|
+
Reset_path = string:concat(getOptionValue("scripts_path="), "/reset_connection_script "),
|
257
|
+
os:cmd(Reset_path),
|
258
|
+
ok.
|
255
259
|
|
256
260
|
|
257
261
|
|
@@ -2,11 +2,21 @@ SocialStream::Presence.setup do |config|
|
|
2
2
|
#Configures XMPP Server Domain
|
3
3
|
config.domain = "localhost"
|
4
4
|
#Configures Bosh Service Path
|
5
|
-
config.bosh_service = "http://
|
6
|
-
#Configures Social Stream Rails App Password
|
7
|
-
config.password = "DnVCB8G|R$VGmZ@2?5=CYS8z)NrL@LuQ<CUh^9B(DF4gC&sQpfbCMbaNKEdNrGYkT4L5zxM0wNWs5q3?ww(b&0d5fK87z^BmgJMMF2SKXT9pEk^UEcch!GX!Avf5GT9)j@FpHe)4RH)BK7J98u!sUmJHUN(Je6aBmn!FtZ4Ab5h8$|nsvUt3Jkq?21HOH$r0sDyJZZvGOCgFS2EKw@0wXsJRHYVRPBe&Eb!1X55e55bQ^h2AW&^R70TK0m)Fu8"
|
5
|
+
#config.bosh_service = "http://xmpp-proxy/http-bind"
|
8
6
|
#Configures XMPP Server Password
|
9
|
-
config.xmpp_server_password = "
|
7
|
+
config.xmpp_server_password = "password"
|
8
|
+
#Remote or local mode
|
9
|
+
config.remote_xmpp_server = false
|
10
|
+
#False to disable Social Stream Presence
|
11
|
+
#config.enable = false
|
12
|
+
|
13
|
+
#Parameters for remote mode
|
10
14
|
#Username of the the Social Stream Admin sid
|
11
15
|
config.social_stream_presence_username = "social_stream-presence"
|
16
|
+
#Configures Social Stream Rails App Password
|
17
|
+
config.password = "password"
|
18
|
+
|
19
|
+
#Parameters for local mode
|
20
|
+
#Scripts path to execute local ejabberd commands
|
21
|
+
config.scripts_path = "/scripts_path"
|
12
22
|
end
|
@@ -1,9 +1,3 @@
|
|
1
|
-
require 'xmpp4r'
|
2
|
-
require 'xmpp4r/muc'
|
3
|
-
require 'xmpp4r/roster'
|
4
|
-
require 'xmpp4r/client'
|
5
|
-
require 'xmpp4r/message'
|
6
|
-
|
7
1
|
module SocialStream
|
8
2
|
module Presence
|
9
3
|
class Engine < Rails::Engine
|
@@ -15,48 +9,7 @@ module SocialStream
|
|
15
9
|
end
|
16
10
|
|
17
11
|
end
|
18
|
-
|
19
|
-
initializer "social_stream-presence.synchronize" do
|
20
|
-
#Synchronize User Presence
|
21
|
-
#Reset connected users when XMMP Server Down
|
22
|
-
Thread.start {
|
23
|
-
begin
|
24
|
-
#XMPP DOMAIN
|
25
|
-
domain = SocialStream::Presence.domain
|
26
|
-
#PASSWORD
|
27
|
-
password= SocialStream::Presence.password
|
28
|
-
#SS Username
|
29
|
-
ss_name = SocialStream::Presence.social_stream_presence_username
|
30
|
-
|
31
|
-
ss_sid = ss_name + "@" + domain
|
32
|
-
client = Jabber::Client.new(Jabber::JID.new(ss_sid))
|
33
|
-
client.connect
|
34
|
-
client.auth(password)
|
35
|
-
|
36
|
-
msg = Jabber::Message::new(ss_sid, "Synchronize")
|
37
|
-
msg.type=:chat
|
38
|
-
client.send(msg)
|
39
|
-
client.close()
|
40
|
-
|
41
|
-
rescue Exception => e
|
42
|
-
case e
|
43
|
-
when Errno::ECONNREFUSED
|
44
|
-
begin
|
45
|
-
users = User.find_all_by_connected(true)
|
46
|
-
users.each do |user|
|
47
|
-
user.connected = false
|
48
|
-
user.save!
|
49
|
-
end
|
50
|
-
puts "Connection to XMPP Server refused: Reset Connected Users"
|
51
|
-
rescue
|
52
|
-
end
|
53
|
-
else
|
54
|
-
puts "Unknown exception: #{e.to_s}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
12
|
+
|
60
13
|
end
|
61
14
|
end
|
62
15
|
end
|