social_stream-presence 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/xmpp_controller.rb +4 -0
- data/app/views/xmpp/_chat.html.erb +8 -2
- data/config/routes.rb +1 -0
- data/ejabberd/conf/ssconfig_example.cfg +3 -0
- data/ejabberd/ejabberd_scripts/emanagement +96 -11
- data/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
- data/lib/social_stream/presence/version.rb +1 -1
- metadata +20 -4
@@ -125,6 +125,10 @@ class XmppController < ApplicationController
|
|
125
125
|
return params[:password] == SocialStream::Presence.xmpp_server_password
|
126
126
|
end
|
127
127
|
|
128
|
+
def chatAuthWithCookie
|
129
|
+
cookie = params[:cookie]
|
130
|
+
render :text => "Ok"
|
131
|
+
end
|
128
132
|
|
129
133
|
def chatWindow
|
130
134
|
if (current_user) and (current_user.status != 'disable') and (params[:userConnected]=="true")
|
@@ -9,8 +9,8 @@
|
|
9
9
|
<%= javascript_include_tag 'xmpp_client'%>
|
10
10
|
<%= javascript_include_tag 'store'%>
|
11
11
|
<% end %>
|
12
|
-
|
13
12
|
|
13
|
+
|
14
14
|
<script type="text/javascript">
|
15
15
|
|
16
16
|
//Global variables
|
@@ -19,7 +19,13 @@
|
|
19
19
|
var user_name = '<%=current_user.name%>';
|
20
20
|
var user_slug = '<%=current_user.slug%>';
|
21
21
|
var user_jid = '<%=current_user.slug%>'+"@"+domain;
|
22
|
-
var sound_path = "/assets/audio/chat/onMessage"
|
22
|
+
var sound_path = "/assets/audio/chat/onMessage";
|
23
|
+
var cookie = "<%=cookies["_global_session"]%>";
|
24
|
+
|
25
|
+
function connectToServerWithCookie(){
|
26
|
+
connection = new Strophe.Connection(BOSH_SERVICE);
|
27
|
+
connection.connect(user_jid, cookie, onConnect);
|
28
|
+
}
|
23
29
|
|
24
30
|
function connectToServer(chatPassword){
|
25
31
|
<%unless current_user.nil? %>
|
data/config/routes.rb
CHANGED
@@ -33,6 +33,7 @@ end
|
|
33
33
|
#Configuration variables
|
34
34
|
$domain = getOption("server_domain=")
|
35
35
|
|
36
|
+
|
36
37
|
PARAMS_FOR_COMMANDS = {
|
37
38
|
'addBuddyToRoster' => 5,
|
38
39
|
'removeBuddyFromRoster' => 2,
|
@@ -54,6 +55,7 @@ PARAMS_FOR_COMMANDS = {
|
|
54
55
|
'sendMessageToUser' => 3,
|
55
56
|
'getUserResource' => 1,
|
56
57
|
'isEjabberdNodeStarted' => 0,
|
58
|
+
'checkEjabberdctlQuotedString' => 0,
|
57
59
|
'help' => 0,
|
58
60
|
}
|
59
61
|
|
@@ -78,6 +80,7 @@ SYNTAX_FOR_COMMANDS = {
|
|
78
80
|
'sendMessageToUser' => 'sendMessageToUser from_name to_name msg',
|
79
81
|
'getUserResource' => 'getUserResource username',
|
80
82
|
'isEjabberdNodeStarted' => 'isEjabberdNodeStarted',
|
83
|
+
'checkEjabberdctlQuotedString' => 'checkEjabberdctlQuotedString',
|
81
84
|
'help' => 'help',
|
82
85
|
}
|
83
86
|
|
@@ -123,7 +126,7 @@ def addBuddyToRoster(userSid,buddySid,buddyNick,buddyGroup,subscription_type)
|
|
123
126
|
buddy = buddySid.split("@")[0]
|
124
127
|
userDomain = userSid.split("@")[1]
|
125
128
|
buddyDomain = buddySid.split("@")[1]
|
126
|
-
command = "ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " +
|
129
|
+
command = buildCommand("ejabberdctl add-rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain + " " + buddyNick + " " + buddyGroup + " " + subscription_type)
|
127
130
|
%x[#{command}];
|
128
131
|
return "Done"
|
129
132
|
end
|
@@ -134,7 +137,7 @@ def removeBuddyFromRoster(userSid,buddySid)
|
|
134
137
|
userDomain = userSid.split("@")[1]
|
135
138
|
buddyDomain = buddySid.split("@")[1]
|
136
139
|
if checkUserInRoster(buddy,getRoster(user))
|
137
|
-
command = "ejabberdctl delete_rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain
|
140
|
+
command = buildCommand("ejabberdctl delete_rosteritem " + user + " " + userDomain + " " + buddy + " " + buddyDomain)
|
138
141
|
%x[#{command}];
|
139
142
|
return "Done"
|
140
143
|
else
|
@@ -147,7 +150,7 @@ end
|
|
147
150
|
|
148
151
|
def getRoster(username)
|
149
152
|
if checkUser(username)
|
150
|
-
command = "ejabberdctl get_roster " + username + " " + $domain
|
153
|
+
command = buildCommand("ejabberdctl get_roster " + username + " " + $domain)
|
151
154
|
%x[#{command}];
|
152
155
|
else
|
153
156
|
return "User " + username + " not found"
|
@@ -179,13 +182,13 @@ def removeRoster(username)
|
|
179
182
|
end
|
180
183
|
|
181
184
|
def removeAllRosters()
|
182
|
-
command = "ejabberdctl process_rosteritems delete any any any any"
|
185
|
+
command = buildCommand("ejabberdctl process_rosteritems delete any any any any")
|
183
186
|
%x[#{command}];
|
184
187
|
return "Done";
|
185
188
|
end
|
186
189
|
|
187
190
|
def getAllUsersWithRoster()
|
188
|
-
command = "ejabberdctl process_rosteritems list any any any any"
|
191
|
+
command = buildCommand("ejabberdctl process_rosteritems list any any any any")
|
189
192
|
output = %x[#{command}];
|
190
193
|
|
191
194
|
i = 0
|
@@ -286,7 +289,7 @@ end
|
|
286
289
|
def sendStanzaUserMessage(username,msg)
|
287
290
|
resource = getUserResource(username);
|
288
291
|
stanza = "\\<\\'message\\'\\>\\<\\'body\\'\\>\\'" + msg + "\\'\\<\\'/body\\'\\>\\<\\'/message\\'\\>"
|
289
|
-
command = "ejabberdctl send_stanza_c2s " + username + " " + $domain + " " + resource + " " + stanza
|
292
|
+
command = buildCommand("ejabberdctl send_stanza_c2s " + username + " " + $domain + " " + resource + " " + stanza)
|
290
293
|
puts "Executing: " + command
|
291
294
|
%x[#{command}];
|
292
295
|
return "Done"
|
@@ -311,7 +314,7 @@ def sendPresenceWithShow(from_name,to_name,show)
|
|
311
314
|
from_sid = from_name + "@" + $domain;
|
312
315
|
to_sid = to_name + "@" + $domain;
|
313
316
|
pres_stanza = "\\<\\'presence from=\\'\\\"\\'" + from_sid + "\\'\\\"\\' to=\\'\\\"\\'" + to_sid + "\\'\\\"\\>\\<\\'show\\'\\>\\'" + show + "\\'\\<\\'/show\\'\\>\\<\\'/presence\\'\\>"
|
314
|
-
command = "ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza
|
317
|
+
command = buildCommand("ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza)
|
315
318
|
puts "Executing: " + command
|
316
319
|
%x[#{command}];
|
317
320
|
return "Done"
|
@@ -322,7 +325,7 @@ def sendPresenceStanzaWithType(from_name,to_name,presence_type)
|
|
322
325
|
from_sid = from_name + "@" + $domain;
|
323
326
|
to_sid = to_name + "@" + $domain;
|
324
327
|
pres_stanza = "\\<\\'presence type=\\'\\\"\\'" + presence_type + "\\'\\\"\\' from=\\'\\\"\\'" + from_sid + "\\'\\\"\\' to=\\'\\\"\\'" + to_sid + "\\'\\\"\\>\\<\\'/presence\\'\\>"
|
325
|
-
command = "ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza
|
328
|
+
command = buildCommand("ejabberdctl send_stanza_c2s " + from_name + " " + $domain + " " + resource + " " + pres_stanza)
|
326
329
|
puts "Executing: " + command
|
327
330
|
%x[#{command}];
|
328
331
|
return "Done"
|
@@ -331,14 +334,14 @@ end
|
|
331
334
|
def sendMessageToUser(from_name,to_name,msg)
|
332
335
|
from_sid = from_name + "@" + $domain;
|
333
336
|
to_sid = to_name + "@" + $domain;
|
334
|
-
command = "ejabberdctl send_message_chat " + from_sid + " " + to_sid + " " +
|
337
|
+
command = buildCommand("ejabberdctl send_message_chat " + from_sid + " " + to_sid + " " + buildQuotedString(msg))
|
335
338
|
puts "Executing: " + command
|
336
339
|
%x[#{command}];
|
337
340
|
return "Done"
|
338
341
|
end
|
339
342
|
|
340
343
|
def getUserResource(username)
|
341
|
-
command = "ejabberdctl connected-users"
|
344
|
+
command = buildCommand("ejabberdctl connected-users")
|
342
345
|
output = %x[#{command}];
|
343
346
|
lines = output.split("\n");
|
344
347
|
lines.each do |line|
|
@@ -356,7 +359,7 @@ end
|
|
356
359
|
#More utilities
|
357
360
|
|
358
361
|
def isEjabberdNodeStarted
|
359
|
-
command = "ejabberdctl status"
|
362
|
+
command = buildCommand("ejabberdctl status")
|
360
363
|
output = %x[#{command}]
|
361
364
|
if firstLine = output.split("\n")[0]
|
362
365
|
return ((firstLine.split(":")[1]).strip()=="started")
|
@@ -364,10 +367,92 @@ def isEjabberdNodeStarted
|
|
364
367
|
return false
|
365
368
|
end
|
366
369
|
|
370
|
+
def checkEjabberdctlQuotedString
|
371
|
+
puts "checkForSimpleSlash: " + checkForSimpleSlash.to_s()
|
372
|
+
puts "checkForDoubleSlash: " + checkForDoubleSlash.to_s()
|
373
|
+
end
|
374
|
+
|
375
|
+
def checkForDoubleSlash
|
376
|
+
command = "ejabberdctl send_message_chat example@localhost example@localhost \\'Hello quoted string\\'"
|
377
|
+
if execute_as_sudo
|
378
|
+
command = "sudo " + command
|
379
|
+
end
|
380
|
+
#puts "Executing " + command
|
381
|
+
output = %x[#{command}]
|
382
|
+
firstLine = ""
|
383
|
+
lines = output.split("\n")
|
384
|
+
lines.each do |line|
|
385
|
+
if line != ""
|
386
|
+
firstLine = line
|
387
|
+
break
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
if firstLine==""
|
392
|
+
return true
|
393
|
+
elsif firstLine.split(":")[0]=="Error"
|
394
|
+
return false
|
395
|
+
else
|
396
|
+
#Unknown error
|
397
|
+
return false
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
def checkForSimpleSlash
|
402
|
+
command = "ejabberdctl send_message_chat example@localhost example@localhost \'Hello quoted string\'"
|
403
|
+
if execute_as_sudo
|
404
|
+
command = "sudo " + command
|
405
|
+
end
|
406
|
+
#puts "Executing " + command
|
407
|
+
output = %x[#{command}]
|
408
|
+
firstLine = ""
|
409
|
+
lines = output.split("\n")
|
410
|
+
lines.each do |line|
|
411
|
+
if line != ""
|
412
|
+
firstLine = line
|
413
|
+
break
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
if firstLine==""
|
418
|
+
return true
|
419
|
+
elsif firstLine.split(":")[0]=="Error"
|
420
|
+
return false
|
421
|
+
else
|
422
|
+
#Unknown error
|
423
|
+
return false
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
def buildQuotedString(msg)
|
428
|
+
if checkForSimpleSlash
|
429
|
+
return "\'" + msg + "\'"
|
430
|
+
end
|
431
|
+
if checkForDoubleSlash
|
432
|
+
return "\\'" + msg + "\\'"
|
433
|
+
end
|
434
|
+
return msg
|
435
|
+
end
|
367
436
|
|
368
437
|
|
369
438
|
#Help & Support methods
|
370
439
|
|
440
|
+
def buildCommand(command)
|
441
|
+
if execute_as_sudo
|
442
|
+
command = "sudo " + command
|
443
|
+
end
|
444
|
+
return command
|
445
|
+
end
|
446
|
+
|
447
|
+
def execute_as_sudo
|
448
|
+
current_user = %x["whoami"].split("\n")[0]
|
449
|
+
sudo_users = getOption("users_require_sudo=")
|
450
|
+
sudo_users_array = sudo_users.split(",")
|
451
|
+
if sudo_users_array.include?(current_user)
|
452
|
+
return true
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
371
456
|
def help
|
372
457
|
log("Command list")
|
373
458
|
SYNTAX_FOR_COMMANDS.values.each do |command|
|
Binary file
|
metadata
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_stream-presence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 14
|
9
|
+
version: 0.0.14
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
12
|
- Aldo Gordillo
|
@@ -10,7 +14,7 @@ autorequire:
|
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date: 2011-10-
|
17
|
+
date: 2011-10-31 00:00:00 +01:00
|
14
18
|
default_executable:
|
15
19
|
dependencies:
|
16
20
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +25,10 @@ dependencies:
|
|
21
25
|
requirements:
|
22
26
|
- - ~>
|
23
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 9
|
31
|
+
- 18
|
24
32
|
version: 0.9.18
|
25
33
|
type: :runtime
|
26
34
|
version_requirements: *id001
|
@@ -32,6 +40,8 @@ dependencies:
|
|
32
40
|
requirements:
|
33
41
|
- - ">="
|
34
42
|
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
35
45
|
version: "0"
|
36
46
|
type: :runtime
|
37
47
|
version_requirements: *id002
|
@@ -43,6 +53,8 @@ dependencies:
|
|
43
53
|
requirements:
|
44
54
|
- - ">="
|
45
55
|
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
46
58
|
version: "0"
|
47
59
|
type: :development
|
48
60
|
version_requirements: *id003
|
@@ -184,17 +196,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
196
|
requirements:
|
185
197
|
- - ">="
|
186
198
|
- !ruby/object:Gem::Version
|
199
|
+
segments:
|
200
|
+
- 0
|
187
201
|
version: "0"
|
188
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
203
|
none: false
|
190
204
|
requirements:
|
191
205
|
- - ">="
|
192
206
|
- !ruby/object:Gem::Version
|
207
|
+
segments:
|
208
|
+
- 0
|
193
209
|
version: "0"
|
194
210
|
requirements: []
|
195
211
|
|
196
212
|
rubyforge_project: social_stream-presence
|
197
|
-
rubygems_version: 1.
|
213
|
+
rubygems_version: 1.3.7
|
198
214
|
signing_key:
|
199
215
|
specification_version: 3
|
200
216
|
summary: Presence capabilities for Social Stream, the core for building social network websites
|