forked from External/greenlight
		
	Slack Integration (#170)
* slack integration * recomment server variables * recomment server variables
This commit is contained in:
		
				
					committed by
					
						
						Jesus Federico
					
				
			
			
				
	
			
			
			
						parent
						
							924ca25ef1
						
					
				
				
					commit
					a2cfdc838f
				
			
							
								
								
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							@@ -76,3 +76,5 @@ gem 'jquery-datatables-rails', '~> 3.4.0'
 | 
			
		||||
gem 'rails-timeago', '~> 2.0'
 | 
			
		||||
 | 
			
		||||
gem 'http_accept_language'
 | 
			
		||||
 | 
			
		||||
gem 'slack-notifier'
 | 
			
		||||
 
 | 
			
		||||
@@ -186,6 +186,7 @@ GEM
 | 
			
		||||
      json (>= 1.8, < 3)
 | 
			
		||||
      simplecov-html (~> 0.10.0)
 | 
			
		||||
    simplecov-html (0.10.0)
 | 
			
		||||
    slack-notifier (2.1.0)
 | 
			
		||||
    spring (2.0.0)
 | 
			
		||||
      activesupport (>= 4.2)
 | 
			
		||||
    spring-watcher-listen (2.0.1)
 | 
			
		||||
@@ -247,6 +248,7 @@ DEPENDENCIES
 | 
			
		||||
  rails-timeago (~> 2.0)
 | 
			
		||||
  sass-rails (~> 5.0)
 | 
			
		||||
  simplecov
 | 
			
		||||
  slack-notifier
 | 
			
		||||
  spring
 | 
			
		||||
  spring-watcher-listen (~> 2.0.0)
 | 
			
		||||
  sqlite3
 | 
			
		||||
 
 | 
			
		||||
@@ -91,7 +91,7 @@ class BbbController < ApplicationController
 | 
			
		||||
      # the user can join the meeting
 | 
			
		||||
      if user
 | 
			
		||||
        if bbb_res[:returncode] && current_user == user
 | 
			
		||||
          JoinMeetingJob.perform_later(user.encrypted_id, params[:id])
 | 
			
		||||
          JoinMeetingJob.perform_later(user, params[:id], base_url)
 | 
			
		||||
 | 
			
		||||
      # user will be waiting for a moderator
 | 
			
		||||
        else
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,9 @@ class EndMeetingJob < ApplicationJob
 | 
			
		||||
  queue_as :default
 | 
			
		||||
 | 
			
		||||
  def perform(room, meeting)
 | 
			
		||||
 | 
			
		||||
    Rails.configuration.slack_notifier.ping I18n.t('slack.meeting_end', meeting: meeting) if !Rails.configuration.slack_notifier.nil?
 | 
			
		||||
 | 
			
		||||
    ActionCable.server.broadcast "#{room}-#{meeting}_meeting_updates_channel",
 | 
			
		||||
      action: 'meeting_ended'
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,13 @@
 | 
			
		||||
class JoinMeetingJob < ApplicationJob
 | 
			
		||||
  queue_as :default
 | 
			
		||||
 | 
			
		||||
  def perform(room, meeting)
 | 
			
		||||
    ActionCable.server.broadcast "#{room}-#{meeting}_meeting_updates_channel",
 | 
			
		||||
def perform(user, meeting, base_url)
 | 
			
		||||
 | 
			
		||||
    join_message = I18n.t('slack.meeting_join', user: user.name, meeting: meeting) + "(#{base_url})"
 | 
			
		||||
    formatted = Slack::Notifier::Util::LinkFormatter.format(join_message)
 | 
			
		||||
    Rails.configuration.slack_notifier.ping formatted if !Rails.configuration.slack_notifier.nil?
 | 
			
		||||
 | 
			
		||||
    ActionCable.server.broadcast "#{user.encrypted_id}-#{meeting}_meeting_updates_channel",
 | 
			
		||||
      action: 'moderator_joined',
 | 
			
		||||
      moderator: 'joined'
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,11 @@ class RecordingUpdatesJob < ApplicationJob
 | 
			
		||||
  def perform(room, record_id)
 | 
			
		||||
    recording = bbb_get_recordings({recordID: record_id})[:recordings].first
 | 
			
		||||
    full_id = "#{room}-#{recording[:metadata][:"meeting-name"]}"
 | 
			
		||||
 | 
			
		||||
    change = (recording[:metadata][:"gl-listed"] == "true") ? I18n.t('slack.published') : I18n.t('slack.unpublished')
 | 
			
		||||
    slack_message = I18n.t('slack.recording_visibility', meeting: recording[:metadata][:"meeting-name"], change: change)
 | 
			
		||||
    Rails.configuration.slack_notifier.ping slack_message if !Rails.configuration.slack_notifier.nil?
 | 
			
		||||
 | 
			
		||||
    ActionCable.server.broadcast "#{room}_recording_updates_channel",
 | 
			
		||||
      action: 'update',
 | 
			
		||||
      id: record_id,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								config/initializers/slack.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								config/initializers/slack.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
 | 
			
		||||
#
 | 
			
		||||
# Copyright (c) 2016 BigBlueButton Inc. and by respective authors (see below).
 | 
			
		||||
#
 | 
			
		||||
# This program is free software; you can redistribute it and/or modify it under the
 | 
			
		||||
# terms of the GNU Lesser General Public License as published by the Free Software
 | 
			
		||||
# Foundation; either version 3.0 of the License, or (at your option) any later
 | 
			
		||||
# version.
 | 
			
		||||
#
 | 
			
		||||
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
 | 
			
		||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 | 
			
		||||
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
# You should have received a copy of the GNU Lesser General Public License along
 | 
			
		||||
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
def uri?(string)
 | 
			
		||||
  uri = URI.parse(string)
 | 
			
		||||
  %w( http https ).include?(uri.scheme)
 | 
			
		||||
rescue URI::BadURIError
 | 
			
		||||
  false
 | 
			
		||||
rescue URI::InvalidURIError
 | 
			
		||||
  false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if !ENV['SLACK_WEBHOOK'].nil? && !ENV['SLACK_WEBHOOK'].empty? && uri?(ENV['SLACK_WEBHOOK']) then
 | 
			
		||||
  # Initialize the slack notifier.
 | 
			
		||||
  Rails.application.config.slack_notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK'] do
 | 
			
		||||
    defaults channel: ENV['SLACK_CHANNEL'],
 | 
			
		||||
             username: "BigBlueButton",
 | 
			
		||||
             icon_url: 'https://avatars3.githubusercontent.com/u/230228?v=3&s=200'
 | 
			
		||||
  end
 | 
			
		||||
else
 | 
			
		||||
  # Initialize it to nil (slack not configured)
 | 
			
		||||
  Rails.application.config.slack_notifier = nil
 | 
			
		||||
end
 | 
			
		||||
@@ -134,6 +134,12 @@ en-US:
 | 
			
		||||
  return_to_room: Return to main page
 | 
			
		||||
  session_url_explanation: The meeting will be taking place using the following URL
 | 
			
		||||
  signin_text: Log in with %{provider}
 | 
			
		||||
  slack:
 | 
			
		||||
    meeting_end: "%{meeting} has ended."
 | 
			
		||||
    meeting_join: "%{user} joined %{meeting}.\n[Click here join!]"
 | 
			
		||||
    recording_visibility: "A recording of %{meeting} was %{change}"
 | 
			
		||||
    published: published
 | 
			
		||||
    unpublished: unpublished
 | 
			
		||||
  start: Start
 | 
			
		||||
  start_join: Start
 | 
			
		||||
  start_meeting: Start meeting
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								env
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								env
									
									
									
									
									
								
							@@ -6,7 +6,6 @@
 | 
			
		||||
#   docker run --rm bigbluebutton/greenlight rake secret
 | 
			
		||||
#
 | 
			
		||||
SECRET_KEY_BASE=
 | 
			
		||||
 | 
			
		||||
# Step 2 - Enter credentials for your BigBlueButton Server
 | 
			
		||||
#
 | 
			
		||||
# The endpoint and secret from your bigbluebutton server.  To get these values, run
 | 
			
		||||
@@ -47,6 +46,16 @@ GOOGLE_OAUTH2_SECRET=
 | 
			
		||||
# the application when recordings are done).
 | 
			
		||||
GREENLIGHT_USE_WEBHOOKS=false
 | 
			
		||||
 | 
			
		||||
# Slack Integration (optional)
 | 
			
		||||
#
 | 
			
		||||
#   You will need to register an incoming-webhook for your slack channel
 | 
			
		||||
#   in order for GreenLight to post to it. You can do this by going
 | 
			
		||||
#   to https://slack.com/apps/A0F7XDUAZ-incoming-webhooks, selecting your
 | 
			
		||||
#   team and then selecting "Add Incoming WebHooks integration" on the
 | 
			
		||||
#   desired channel. You will then need to paste the webhook below.
 | 
			
		||||
#
 | 
			
		||||
SLACK_WEBHOOK=
 | 
			
		||||
SLACK_CHANNEL=
 | 
			
		||||
 | 
			
		||||
# SMTP Mailer
 | 
			
		||||
#
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user