social_stream 0.11.2 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/Gemfile +0 -9
  2. data/base/app/assets/stylesheets/contacts.css.scss +8 -3
  3. data/base/app/assets/stylesheets/frontpage.css.scss +1 -1
  4. data/base/app/assets/stylesheets/search.css.scss +17 -1
  5. data/base/app/controllers/contacts_controller.rb +2 -5
  6. data/base/app/models/contact.rb +3 -2
  7. data/base/app/views/activities/_options.html.erb +1 -1
  8. data/base/app/views/contacts/_form.html.erb +14 -7
  9. data/base/app/views/frontpage/_social_networks.html.erb +3 -0
  10. data/base/app/views/groups/_new.html.erb +2 -2
  11. data/base/app/views/groups/_show.html.erb +1 -2
  12. data/base/app/views/groups/index.html.erb +1 -1
  13. data/base/app/views/layouts/_header_signed_out.erb +1 -3
  14. data/base/app/views/notifications/activities/_follow_subject.html.erb +5 -2
  15. data/base/app/views/notifications/activities/_like_subject.html.erb +6 -2
  16. data/base/app/views/notifications/activities/_make-friend_subject.html.erb +5 -2
  17. data/base/app/views/notifications/activities/_post_subject.html.erb +6 -1
  18. data/base/app/views/notifications/activities/_update_body.html.erb +5 -1
  19. data/base/app/views/notifications/activities/_update_subject.html.erb +5 -1
  20. data/base/app/views/posts/_post_focus_search.html.erb +37 -3
  21. data/base/app/views/posts/_post_global_search.html.erb +2 -0
  22. data/base/app/views/profiles/_contact.html.erb +1 -1
  23. data/base/app/views/search/index.js.erb +2 -0
  24. data/base/app/views/toolbar/_home.html.erb +4 -0
  25. data/base/config/locales/en.yml +26 -0
  26. data/base/config/locales/es.yml +26 -0
  27. data/base/lib/mailboxer/notification_decoder.rb +8 -6
  28. data/base/lib/social_stream-base.rb +1 -1
  29. data/base/lib/social_stream/base/version.rb +1 -1
  30. data/base/lib/social_stream/migrations/components.rb +1 -1
  31. data/base/lib/social_stream/toolbar_config/base.rb +12 -1
  32. data/base/social_stream-base.gemspec +1 -1
  33. data/base/spec/controllers/contacts_controller_spec.rb +4 -4
  34. data/events/app/assets/javascripts/social_stream-events.js +2 -2
  35. data/events/app/assets/stylesheets/social_stream-events.css +3 -0
  36. data/events/{app → vendor}/assets/javascripts/jquery.ad-gallery.js +0 -0
  37. data/events/{app → vendor}/assets/javascripts/jquery.ad-gallery.pack.js +0 -0
  38. data/events/{app → vendor}/assets/stylesheets/ad_next.png +0 -0
  39. data/events/{app → vendor}/assets/stylesheets/ad_prev.png +0 -0
  40. data/events/{app → vendor}/assets/stylesheets/ad_scroll_back.png +0 -0
  41. data/events/{app → vendor}/assets/stylesheets/ad_scroll_forward.png +0 -0
  42. data/events/{app → vendor}/assets/stylesheets/fullcalendar.css +0 -0
  43. data/events/{app → vendor}/assets/stylesheets/fullcalendar.print.css +0 -0
  44. data/events/{app → vendor}/assets/stylesheets/jquery.ad-gallery.css +0 -0
  45. data/events/{app → vendor}/assets/stylesheets/loader.gif +0 -0
  46. data/events/vendor/assets/stylesheets/social_stream-events.css +273 -0
  47. data/lib/social_stream.rb +0 -4
  48. data/lib/social_stream/version.rb +1 -1
  49. data/presence/.gitignore +4 -0
  50. data/presence/Gemfile +4 -0
  51. data/presence/Rakefile +1 -0
  52. data/presence/app/assets/audio/chat/onMessageAudio.mp3 +0 -0
  53. data/presence/app/assets/audio/chat/onMessageAudio.wav +0 -0
  54. data/presence/app/assets/images/arrow.png +0 -0
  55. data/presence/app/assets/images/black_arrow3.png +0 -0
  56. data/presence/app/assets/images/status/available.png +0 -0
  57. data/presence/app/assets/images/status/away.png +0 -0
  58. data/presence/app/assets/images/status/dnd.png +0 -0
  59. data/presence/app/assets/javascripts/jquery-ui-1.8.14.custom.min.js +789 -0
  60. data/presence/app/assets/javascripts/jquery.tools.min.js +17 -0
  61. data/presence/app/assets/javascripts/jquery.tools.tooltip.js +11 -0
  62. data/presence/app/assets/javascripts/jquery.ui.chatbox.js +260 -0
  63. data/presence/app/assets/javascripts/social_stream-presence.js +2 -0
  64. data/presence/app/assets/javascripts/store.js +27 -0
  65. data/presence/app/assets/javascripts/strophe.js +3612 -0
  66. data/presence/app/assets/javascripts/xmpp_client.js +498 -0
  67. data/presence/app/assets/stylesheets/chat.css +231 -0
  68. data/presence/app/assets/stylesheets/jquery.ui.chatbox.css +54 -0
  69. data/presence/app/assets/stylesheets/social_stream-presence.css +3 -0
  70. data/presence/app/controllers/xmpp_controller.rb +190 -0
  71. data/presence/app/helpers/xmpp_helper.rb +33 -0
  72. data/presence/app/views/xmpp/_chat.html.erb +59 -0
  73. data/presence/app/views/xmpp/_chat_connecting.html.erb +8 -0
  74. data/presence/app/views/xmpp/_chat_contacts.html.erb +46 -0
  75. data/presence/app/views/xmpp/_chat_off.html.erb +35 -0
  76. data/presence/app/views/xmpp/active_users.html.erb +33 -0
  77. data/presence/app/views/xmpp/chat.html.erb +13 -0
  78. data/presence/app/views/xmpp/index.html +19 -0
  79. data/presence/app/views/xmpp/test.html.erb +11 -0
  80. data/presence/config/routes.rb +15 -0
  81. data/presence/db/migrate/20110711111408_add_connected_column_to_user.rb +9 -0
  82. data/presence/db/migrate/20110928135031_add_status_column_to_user.rb +9 -0
  83. data/presence/ejabberd/conf/ejabberd.cfg +625 -0
  84. data/presence/ejabberd/conf/ejabberdctl.cfg +154 -0
  85. data/presence/ejabberd/conf/inetrc +3 -0
  86. data/presence/ejabberd/conf/server.pem +37 -0
  87. data/presence/ejabberd/conf/ssconfig.cfg +29 -0
  88. data/presence/ejabberd/ejabberd_scripts/authentication_script +117 -0
  89. data/presence/ejabberd/ejabberd_scripts/authentication_script_org +114 -0
  90. data/presence/ejabberd/ejabberd_scripts/compile_module +34 -0
  91. data/presence/ejabberd/ejabberd_scripts/generate_random_password +18 -0
  92. data/presence/ejabberd/ejabberd_scripts/kill_authentication_script.sh +13 -0
  93. data/presence/ejabberd/ejabberd_scripts/reset_connection_script +55 -0
  94. data/presence/ejabberd/ejabberd_scripts/reset_logs.sh +23 -0
  95. data/presence/ejabberd/ejabberd_scripts/set_connection_script +48 -0
  96. data/presence/ejabberd/ejabberd_scripts/set_presence_script +48 -0
  97. data/presence/ejabberd/ejabberd_scripts/show_config.sh +30 -0
  98. data/presence/ejabberd/ejabberd_scripts/start_ejabberd.sh +68 -0
  99. data/presence/ejabberd/ejabberd_scripts/stop_ejabberd.sh +12 -0
  100. data/presence/ejabberd/ejabberd_scripts/synchronize_presence_script +57 -0
  101. data/presence/ejabberd/ejabberd_scripts/unset_connection_script +48 -0
  102. data/presence/ejabberd/mod_admin_extra/mod_admin_extra.beam +0 -0
  103. data/presence/ejabberd/mod_admin_extra/mod_admin_extra.erl +1560 -0
  104. data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +230 -0
  105. data/presence/lib/social_stream-presence.rb +13 -0
  106. data/presence/lib/social_stream/migrations/presence.rb +9 -0
  107. data/presence/lib/social_stream/presence/config.rb +9 -0
  108. data/presence/lib/social_stream/presence/engine.rb +49 -0
  109. data/presence/lib/social_stream/presence/models/buddy_manager.rb +67 -0
  110. data/presence/social_stream-presence.gemspec +28 -0
  111. data/presence/spec/demo/.gitignore +5 -0
  112. data/presence/spec/demo/.rspec +1 -0
  113. data/presence/spec/demo/README +261 -0
  114. data/presence/spec/demo/Rakefile +7 -0
  115. data/presence/spec/demo/app/assets/images/rails.png +0 -0
  116. data/presence/spec/demo/app/assets/javascripts/application.js +9 -0
  117. data/presence/spec/demo/app/assets/stylesheets/application.css +7 -0
  118. data/presence/spec/demo/app/controllers/application_controller.rb +3 -0
  119. data/presence/spec/demo/app/helpers/application_helper.rb +2 -0
  120. data/presence/spec/demo/app/mailers/.gitkeep +0 -0
  121. data/presence/spec/demo/app/models/.gitkeep +0 -0
  122. data/presence/spec/demo/app/views/layouts/application.html.erb +14 -0
  123. data/presence/spec/demo/autotest/discover.rb +2 -0
  124. data/presence/spec/demo/config.ru +4 -0
  125. data/presence/spec/demo/config/application.rb +41 -0
  126. data/presence/spec/demo/config/boot.rb +6 -0
  127. data/presence/spec/demo/config/database.yml +25 -0
  128. data/presence/spec/demo/config/environment.rb +5 -0
  129. data/presence/spec/demo/config/environments/development.rb +27 -0
  130. data/presence/spec/demo/config/environments/production.rb +54 -0
  131. data/presence/spec/demo/config/environments/test.rb +39 -0
  132. data/presence/spec/demo/config/initializers/backtrace_silencers.rb +7 -0
  133. data/presence/spec/demo/config/initializers/inflections.rb +10 -0
  134. data/presence/spec/demo/config/initializers/mime_types.rb +5 -0
  135. data/presence/spec/demo/config/initializers/secret_token.rb +7 -0
  136. data/presence/spec/demo/config/initializers/session_store.rb +8 -0
  137. data/presence/spec/demo/config/initializers/wrap_parameters.rb +12 -0
  138. data/presence/spec/demo/config/locales/en.yml +5 -0
  139. data/presence/spec/demo/config/routes.rb +58 -0
  140. data/presence/spec/demo/db/seeds.rb +7 -0
  141. data/presence/spec/demo/doc/README_FOR_APP +2 -0
  142. data/presence/spec/demo/lib/tasks/.gitkeep +0 -0
  143. data/presence/spec/demo/log/.gitkeep +0 -0
  144. data/presence/spec/demo/public/404.html +26 -0
  145. data/presence/spec/demo/public/422.html +26 -0
  146. data/presence/spec/demo/public/500.html +26 -0
  147. data/presence/spec/demo/public/favicon.ico +0 -0
  148. data/presence/spec/demo/public/index.html +241 -0
  149. data/presence/spec/demo/public/robots.txt +5 -0
  150. data/presence/spec/demo/script/rails +6 -0
  151. data/presence/spec/demo/spec/spec_helper.rb +27 -0
  152. data/presence/spec/demo/test/fixtures/.gitkeep +0 -0
  153. data/presence/spec/demo/test/functional/.gitkeep +0 -0
  154. data/presence/spec/demo/test/integration/.gitkeep +0 -0
  155. data/presence/spec/demo/test/performance/browsing_test.rb +12 -0
  156. data/presence/spec/demo/test/test_helper.rb +13 -0
  157. data/presence/spec/demo/test/unit/.gitkeep +0 -0
  158. data/presence/spec/demo/vendor/assets/stylesheets/.gitkeep +0 -0
  159. data/presence/spec/demo/vendor/plugins/.gitkeep +0 -0
  160. data/presence/spec/discover.rb +2 -0
  161. data/presence/spec/spec_helper.rb +27 -0
  162. data/social_stream.gemspec +9 -2
  163. data/spec/dummy/config/environments/{test_pg.rb → test_mysql.rb} +6 -2
  164. data/spec/dummy/config/environments/test_postgres.rb +39 -0
  165. data/spec/spec_helper.rb +1 -4
  166. metadata +135 -21
  167. data/base/app/views/groups/_new_activity.html.erb +0 -1
  168. data/base/app/views/groups/_new_activity_fields.html.erb +0 -7
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ def getOption(option)
5
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
6
+ while line = f1.gets
7
+ line = line.gsub(/\n/,'')
8
+ if line.match(/^#/)
9
+ #Comments
10
+ elsif line.match(/^#{option}/)
11
+ return line.gsub(/#{option}/,'')
12
+ end
13
+ end
14
+ end
15
+ return "Undefined"
16
+ end
17
+
18
+
19
+
20
+
21
+ source_path = getOption("source_path=")
22
+
23
+ if source_path == "Undefined"
24
+ #puts "mod_sspresence source_path in undefined: define source_path in /etc/ejabberd/ssconfig.cfg to compile mod_sspresence"
25
+ puts "mod_sspresence source_path in undefined: Exit compile"
26
+ else
27
+ puts "Compile mod_sspresence"
28
+ system("erlc #{source_path}/mod_sspresence.erl")
29
+ system 'sudo mv mod_sspresence.beam /lib/ejabberd/ebin/mod_sspresence.beam'
30
+ puts "Compile mod_sspresence OK"
31
+ end
32
+
33
+
34
+
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ def newpass(l)
4
+ chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!$%&()=?|@^*'
5
+ password = ''
6
+ l.downto(1) { |i| password << chars[rand(chars.length - 1)] }
7
+ return password
8
+ end
9
+
10
+ puts "Generate random password"
11
+
12
+ unless ARGV[0]
13
+ puts "Error: Password lenght argument missed"
14
+ exit
15
+ else
16
+ puts ARGV[0]
17
+ puts newpass(Integer(ARGV[0]))
18
+ end
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+
3
+ echo "Kill All Authentication Scripts"
4
+
5
+ for pid in `ps -aef | grep './authentication_script' | grep -v grep | awk '{print $2}'`
6
+ do
7
+ echo $pid
8
+ kill -9 $pid
9
+ done
10
+
11
+
12
+
13
+
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ #Reset Connection Script
3
+ #@author Aldo
4
+
5
+ require 'logger'
6
+ require 'rest_client'
7
+
8
+ path = "/var/log/ejabberd/scripts.log"
9
+ file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
10
+ file.sync = true
11
+ $logger = Logger.new(file)
12
+ $logger.level = Logger::DEBUG
13
+
14
+ def getOption(option)
15
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
16
+ while line = f1.gets
17
+ line = line.gsub(/\n/,'')
18
+ if line.match(/^#/)
19
+ #Comments
20
+ elsif line.match(/^#{option}/)
21
+ return line.gsub(/#{option}/,'')
22
+ end
23
+ end
24
+ end
25
+ return "Undefined"
26
+ end
27
+
28
+ $url = getOption("reset_connection_api=")
29
+ $pass = getOption("ejabberd_password=")
30
+
31
+
32
+ def log(text)
33
+ $logger.info "Reset Connection Script: " + text
34
+ end
35
+
36
+
37
+ def resetConnection()
38
+ begin
39
+ RestClient.post($url, :password => $pass)
40
+ return true
41
+ rescue => e
42
+ log("#{e.class.name}: #{e.message}")
43
+ return false
44
+ end
45
+ end
46
+
47
+ if (resetConnection())
48
+ puts "Reset Connection [OK]"
49
+ log( "Reset Connection [OK]" )
50
+ else
51
+ puts "Reset Connection [FAIL]"
52
+ log( "Reset Connection [FAIL]" )
53
+ end
54
+
55
+
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ echo "Starting Reset logs"
4
+
5
+ rm /var/log/ejabberd/auth.log
6
+ rm /var/log/ejabberd/auth_error.log
7
+ rm /var/log/ejabberd/ejabberd.log
8
+ rm /var/log/ejabberd/erlang.log
9
+ rm /var/log/ejabberd/scripts.log
10
+ rm /var/log/ejabberd/erl_crash_*
11
+
12
+ touch /var/log/ejabberd/auth.log
13
+ touch /var/log/ejabberd/auth_error.log
14
+ touch /var/log/ejabberd/ejabberd.log
15
+ touch /var/log/ejabberd/erlang.log
16
+ touch /var/log/ejabberd/scripts.log
17
+ touch /var/log/ejabberd/erl_crash_dummy.log
18
+
19
+ echo "Reset logs OK"
20
+
21
+
22
+
23
+
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ #Set Connection Script
3
+ #@author Aldo
4
+
5
+ require 'logger'
6
+ require 'rest_client'
7
+
8
+ path = "/var/log/ejabberd/scripts.log"
9
+ file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
10
+ file.sync = true
11
+ $logger = Logger.new(file)
12
+ $logger.level = Logger::DEBUG
13
+
14
+ def getOption(option)
15
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
16
+ while line = f1.gets
17
+ line = line.gsub(/\n/,'')
18
+ if line.match(/^#/)
19
+ #Comments
20
+ elsif line.match(/^#{option}/)
21
+ return line.gsub(/#{option}/,'')
22
+ end
23
+ end
24
+ end
25
+ return "Undefined"
26
+ end
27
+
28
+ $url = getOption("set_connection_api=")
29
+ $pass = getOption("ejabberd_password=")
30
+
31
+
32
+ def log(text)
33
+ $logger.info "Set Connection Script: " + text
34
+ end
35
+
36
+ def setConnection(username)
37
+ log("setConnection(#{username})")
38
+ RestClient.post($url, :name => username, :password => $pass)
39
+ return true
40
+
41
+ rescue RestClient::Exception
42
+ log("RestClient::Exception with setConnection(#{username})")
43
+ end
44
+
45
+
46
+ setConnection(ARGV[0])
47
+
48
+
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ #Set Presence Script
3
+ #@author Aldo
4
+
5
+ require 'logger'
6
+ require 'rest_client'
7
+
8
+ path = "/var/log/ejabberd/scripts.log"
9
+ file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
10
+ file.sync = true
11
+ $logger = Logger.new(file)
12
+ $logger.level = Logger::DEBUG
13
+
14
+ def getOption(option)
15
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
16
+ while line = f1.gets
17
+ line = line.gsub(/\n/,'')
18
+ if line.match(/^#/)
19
+ #Comments
20
+ elsif line.match(/^#{option}/)
21
+ return line.gsub(/#{option}/,'')
22
+ end
23
+ end
24
+ end
25
+ return "Undefined"
26
+ end
27
+
28
+ $url = getOption("set_presence_api=")
29
+ $pass = getOption("ejabberd_password=")
30
+
31
+
32
+ def log(text)
33
+ $logger.info "Set Presence Script: " + text
34
+ end
35
+
36
+ def setPresence(username,status)
37
+ log("setPresence(#{username},#{status})")
38
+ RestClient.post($url, :name => username, :status => status, :password => $pass)
39
+ return true
40
+
41
+ rescue RestClient::Exception
42
+ log("RestClient::Exception with setPresence(#{username})")
43
+ end
44
+
45
+
46
+ setPresence(ARGV[0],ARGV[1])
47
+
48
+
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ def getOption(option)
4
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
5
+ while line = f1.gets
6
+ line = line.gsub(/\n/,'')
7
+ if line.match(/^#/)
8
+ #Comments
9
+ elsif line.match(/^#{option}/)
10
+ return line.gsub(/#{option}/,'')
11
+ end
12
+ end
13
+ end
14
+ return "Undefined"
15
+ end
16
+
17
+ puts ""
18
+ puts "############### Ejabberd Configuration ###############"
19
+ puts "Config file for Social Stream Presence: /etc/ejabberd/ssconfig.cfg"
20
+ puts "Scripts Path: #{getOption("scripts_path=")}"
21
+ puts "mod_sspresence Path: #{getOption("source_path=")}"
22
+ puts "API REST URLs"
23
+ puts "Authentication: #{getOption("auth_api=")}"
24
+ puts "onRegisterConnection: #{getOption("set_connection_api=")}"
25
+ puts "onRemoveConnection: #{getOption("unset_connection_api=")}"
26
+ puts "onPresence: #{getOption("set_presence_api=")}"
27
+ puts "onUnsetPresence: #{getOption("unset_presence_api=")}"
28
+ puts "Social Stream Presence logs in var/log/ejabberd/"
29
+ puts "######################################################"
30
+ puts ""
@@ -0,0 +1,68 @@
1
+ #!/bin/bash
2
+
3
+ echo "Stopping ejabberd server"
4
+ sudo ejabberdctl stop
5
+
6
+ if [ $# -lt 1 ]; then
7
+ command="start"
8
+ echo "Starting ejabberd server"
9
+ else
10
+
11
+ param=$1
12
+ logs=true
13
+
14
+ while getopts ":l" opt; do
15
+ case $opt in
16
+ l)
17
+ #-l option
18
+ logs=false
19
+
20
+ if [ $# -lt 2 ]; then
21
+ param="start"
22
+ else
23
+ param=$2
24
+ fi
25
+ ;;
26
+ \?)
27
+ echo "Invalid option: -$OPTARG" >&2
28
+ echo "Use \"$0 help\" to view help"
29
+ exit
30
+ ;;
31
+ esac
32
+ done
33
+
34
+
35
+
36
+ if [ $param == "live" ]; then
37
+ command="live"
38
+ echo "Starting ejabberd server in Live mode"
39
+ elif [ $param == "start" ]; then
40
+ command="start"
41
+ echo "Starting ejabberd server"
42
+ else
43
+ #Show HELP
44
+ echo "Use \"$0 start\" to Start ejabberd server in normal mode"
45
+ echo "Use \"$0 live\" to Start ejabberd server in live mode"
46
+ echo "Use -l option to keep log files"
47
+ exit
48
+ fi
49
+ fi
50
+
51
+
52
+ echo ""
53
+ ./kill_authentication_script.sh
54
+ if $logs; then
55
+ ./reset_logs.sh
56
+ fi
57
+ ./compile_module
58
+ ./reset_connection_script
59
+ ./show_config.sh
60
+
61
+ sudo ejabberdctl $command
62
+ echo "ejabberd server started"
63
+
64
+
65
+
66
+
67
+
68
+
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+
3
+ echo "Stopping ejabberd server"
4
+ sudo ejabberdctl stop
5
+
6
+ ./kill_authentication_script.sh
7
+
8
+ echo "Ejabberd server stoped"
9
+
10
+
11
+
12
+
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ #Presence Script
3
+ #@author Aldo
4
+
5
+ require 'logger'
6
+ require 'rest_client'
7
+
8
+ path = "/var/log/ejabberd/scripts.log"
9
+ file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
10
+ file.sync = true
11
+ $logger = Logger.new(file)
12
+ $logger.level = Logger::DEBUG
13
+
14
+ def getOption(option)
15
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
16
+ while line = f1.gets
17
+ line = line.gsub(/\n/,'')
18
+ if line.match(/^#/)
19
+ #Comments
20
+ elsif line.match(/^#{option}/)
21
+ return line.gsub(/#{option}/,'')
22
+ end
23
+ end
24
+ end
25
+ return "Undefined"
26
+ end
27
+
28
+ $url = getOption("synchronize_presence_api=")
29
+ $pass = getOption("ejabberd_password=")
30
+
31
+
32
+ def log(text)
33
+ $logger.info "Synchronize Presence Script: " + text
34
+ end
35
+
36
+ def synchronize()
37
+ log("Start Synchronize")
38
+
39
+ users = []
40
+ output = %x[ejabberdctl connected-users]
41
+ sessions = output.split("\n")
42
+
43
+ sessions.each do |session|
44
+ users << session.split("@")[0]
45
+ end
46
+
47
+ RestClient.post($url, :name => users, :password => $pass)
48
+ return true
49
+
50
+ rescue RestClient::Exception
51
+ log("RestClient::Exception")
52
+ end
53
+
54
+
55
+ synchronize()
56
+
57
+
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ #Unset Connection Script
3
+ #@author Aldo
4
+
5
+ require 'logger'
6
+ require 'rest_client'
7
+
8
+ path = "/var/log/ejabberd/scripts.log"
9
+ file = File.open(path, File::WRONLY | File::APPEND | File::CREAT)
10
+ file.sync = true
11
+ $logger = Logger.new(file)
12
+ $logger.level = Logger::DEBUG
13
+
14
+ def getOption(option)
15
+ File.open('/etc/ejabberd/ssconfig.cfg', 'r') do |f1|
16
+ while line = f1.gets
17
+ line = line.gsub(/\n/,'')
18
+ if line.match(/^#/)
19
+ #Comments
20
+ elsif line.match(/^#{option}/)
21
+ return line.gsub(/#{option}/,'')
22
+ end
23
+ end
24
+ end
25
+ return "Undefined"
26
+ end
27
+
28
+ $url = getOption("unset_connection_api=")
29
+ $pass = getOption("ejabberd_password=")
30
+
31
+
32
+ def log(text)
33
+ $logger.info "Unset Connection: " + text
34
+ end
35
+
36
+ def unsetConnection(username)
37
+ log("unsetConnection(#{username})")
38
+ RestClient.post($url, :name => username, :password => $pass)
39
+ return true
40
+
41
+ rescue RestClient::Exception
42
+ log("RestClient::Exception with unsetConnection(#{username})")
43
+ end
44
+
45
+
46
+ unsetConnection(ARGV[0])
47
+
48
+