diff --git a/.rubocop.yml b/.rubocop.yml index 36027a718b54dcc8188102785c506c21fb278087..2f7d6e1c78f48dca370f5508eeea7d7a9e01cefe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -61,7 +61,7 @@ Style/FormatString: # Offense count: 1 Style/IfInsideElse: Exclude: - - 'sgx-catapult.rb' + - 'sgx-bwmsgsv2.rb' Style/LeadingCommentSpace: Enabled: false diff --git a/em_promise.rb b/em_promise.rb index ba45e660a949687043490db97a4130603b06894d..b86e04d19d29a29ad3fc9d6c5f5469c6a7993db8 100644 --- a/em_promise.rb +++ b/em_promise.rb @@ -2,20 +2,20 @@ # # Copyright (C) 2017 Stephen Paul Weber # -# This file is part of sgx-catapult. +# This file is part of sgx-bwmsgsv2. # -# sgx-catapult is free software: you can redistribute it and/or modify it under +# sgx-bwmsgsv2 is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # -# sgx-catapult is distributed in the hope that it will be useful, but WITHOUT +# sgx-bwmsgsv2 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 Affero General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License along -# with sgx-catapult. If not, see . +# with sgx-bwmsgsv2. If not, see . require "eventmachine" require "promise" diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 002a9cd2664fe9c6de4198175fba2ba4f6064e1a..b085587053f0163d65cf865044fdb84d38986336 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -3,20 +3,20 @@ # Copyright (C) 2017-2020 Denver Gingerich # Copyright (C) 2017 Stephen Paul Weber # -# This file is part of sgx-catapult. +# This file is part of sgx-bwmsgsv2. # -# sgx-catapult is free software: you can redistribute it and/or modify it under +# sgx-bwmsgsv2 is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # -# sgx-catapult is distributed in the hope that it will be useful, but WITHOUT +# sgx-bwmsgsv2 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 Affero General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License along -# with sgx-catapult. If not, see . +# with sgx-bwmsgsv2. If not, see . require 'blather/client/dsl' require 'em-hiredis' @@ -36,7 +36,7 @@ require_relative 'em_promise' def panic(e) puts "Shutting down gateway due to exception: #{e.message}" puts e.backtrace - SGXcatapult.shutdown + SGXbwmsgsv2.shutdown puts 'Gateway has terminated.' EM.stop end @@ -81,7 +81,7 @@ module CatapultSettingFlagBits MMS_ON_OOB_URL = 1 end -module SGXcatapult +module SGXbwmsgsv2 extend Blather::DSL @jingle_sids = {} @@ -657,7 +657,7 @@ module SGXcatapult end iq '/iq/ns:query', ns: 'http://jabber.org/protocol/disco#info' do |i| - # respond to capabilities request for an sgx-catapult number JID + # respond to capabilities request for an sgx-bwmsgsv2 number JID if i.to.node # TODO: confirm the node URL is expected using below #puts "XR[node]: #{xpath_result[0]['node']}" @@ -672,11 +672,11 @@ module SGXcatapult next end - # respond to capabilities request for sgx-catapult itself + # respond to capabilities request for sgx-bwmsgsv2 itself msg = i.reply msg.node = i.node msg.identities = [{ - name: 'Soprani.ca Gateway to XMPP - Catapult', + name: 'Soprani.ca Gateway to XMPP - Bandwidth API V2', type: 'sms', category: 'gateway' }] msg.features = @gateway_features @@ -839,7 +839,7 @@ module SGXcatapult ".\nUser Id is nick, API Token is username, "\ "API Secret is password, Phone Number is phone"\ ".\n\nThe source code for this gateway is at "\ - "https://gitlab.com/ossguy/sgx-catapult ."\ + "https://gitlab.com/soprani.ca/sgx-bwmsgsv2 ."\ "\nCopyright (C) 2017-2020 Denver Gingerich "\ "and others, licensed under AGPLv3+." n2 = Nokogiri::XML::Node.new 'nick', msg.document @@ -873,12 +873,12 @@ module SGXcatapult } ] x.title = 'Register for '\ - 'Soprani.ca Gateway to XMPP - Catapult' + 'Soprani.ca Gateway to XMPP - Bandwidth API V2' x.instructions = "Enter the details from your Account "\ "page as well as the Phone Number\nin your "\ "account you want to use (ie. '+12345678901')"\ ".\n\nThe source code for this gateway is at "\ - "https://gitlab.com/ossguy/sgx-catapult ."\ + "https://gitlab.com/soprani.ca/sgx-bwmsgsv2 ."\ "\nCopyright (C) 2017-2020 Denver Gingerich "\ "and others, licensed under AGPLv3+." msg.add_child(x) @@ -976,9 +976,9 @@ class WebhookHandler < Goliath::API bare_jid = REDIS.get(jid_key).promise.sync if !bare_jid - puts "jid_key (#{jid_key}) DNE; Catapult misconfigured?" + puts "jid_key (#{jid_key}) DNE; BW API misconfigured?" - # TODO: likely not appropriate; give error to Catapult? + # TODO: likely not appropriate; give error to BW API? # TODO: add text re credentials not being registered #write_to_stream error_msg(m.reply, m.body, :auth, # 'registration-required') @@ -1000,7 +1000,7 @@ class WebhookHandler < Goliath::API ) has_media = true - SGXcatapult.send_media( + SGXbwmsgsv2.send_media( others_num + '@' + ARGV[0], bare_jid, media_url @@ -1031,7 +1031,7 @@ class WebhookHandler < Goliath::API msg = Blather::Stanza::Message.new( bare_jid, text) msg.from = others_num + '@' + ARGV[0] - SGXcatapult.write(msg) + SGXbwmsgsv2.write(msg) end return [200, {}, "OK"] @@ -1092,13 +1092,13 @@ class WebhookHandler < Goliath::API end msg.from = others_num + '@' + ARGV[0] - SGXcatapult.write(msg) + SGXbwmsgsv2.write(msg) [200, {}, "OK"] rescue Exception => e puts 'Shutting down gateway due to exception 013: ' + e.message - SGXcatapult.shutdown + SGXbwmsgsv2.shutdown puts 'Gateway has terminated.' EM.stop end @@ -1107,11 +1107,11 @@ end at_exit do $stdout.sync = true - puts "Soprani.ca/SMS Gateway for XMPP - Catapult\n"\ + puts "Soprani.ca/SMS Gateway for XMPP - Bandwidth API V2\n"\ "==>> last commit of this version is " + `git rev-parse HEAD` + "\n" if ARGV.size != 7 - puts "Usage: sgx-catapult.rb "\ + puts "Usage: sgx-bwmsgsv2.rb "\ " "\ " "\ " " @@ -1124,13 +1124,13 @@ at_exit do EM.run do REDIS = EM::Hiredis.connect - SGXcatapult.run + SGXbwmsgsv2.run # required when using Prosody otherwise disconnects on 6-hour inactivity EM.add_periodic_timer(3600) do msg = Blather::Stanza::Iq::Ping.new(:get, 'localhost') msg.from = ARGV[0] - SGXcatapult.write(msg) + SGXbwmsgsv2.write(msg) end server = Goliath::Server.new('0.0.0.0', ARGV[5].to_i) @@ -1144,7 +1144,7 @@ at_exit do trap(sig) do EM.defer do puts 'Shutting down gateway...' - SGXcatapult.shutdown + SGXbwmsgsv2.shutdown puts 'Gateway has terminated.' EM.stop