Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pibico/atvirtual
Browse files Browse the repository at this point in the history
  • Loading branch information
pibico committed Feb 20, 2021
2 parents 768a320 + 816ca5b commit d071139
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions atvirtual/atvirtual/doctype/pibimessage/pibimessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def before_save(self):
if self.message_type == "Text":
message = "From AT Virtual: " + self.message_text
elif self.message_type == "Photo":
message = "Photo from AT Virtual \n" + frappe.utils.get_url() + ":8080" + urllib.parse.quote(self.message_photo)
message = "Photo from AT Virtual \n" + frappe.utils.get_url() + urllib.parse.quote(self.message_photo)
elif self.message_type == "Video":
message = "Video from AT Virtual \n" + frappe.utils.get_url() + ":8080" + urllib.parse.quote(self.message_video)
message = "Video from AT Virtual \n" + frappe.utils.get_url() + urllib.parse.quote(self.message_video)

if len(sms_list) > 0:
try:
Expand All @@ -85,19 +85,24 @@ def before_save(self):
except:
pass
if len(mqtt_list) > 0:
path = "/home/erpnext/erpnext-dev/sites/"
path = frappe.utils.get_bench_path()
site_name = frappe.utils.get_url().replace("http://","").replace("https://","")
if ":" in site_name:
pos = site_name.find(":")
site_name = site_name[:pos]

client = frappe.get_doc('MQTT Settings', 'MQTT Settings')
server = client.broker_gateway
port = client.port
user = client.user
client.secret = get_decrypted_password('MQTT Settings', 'MQTT Settings', 'secret', False)
secret = client.secret
do_ssl = client.is_ssl
ca = path + frappe.utils.get_url().replace("http://","") + client.ca
client_crt = path + frappe.utils.get_url().replace("http://","") + client.client_crt
client_key = path + frappe.utils.get_url().replace("http://","") + client.client_key
#ca = path + "/sites/" + frappe.get_site_path('private', 'files', client.ca)[1:]
ca = os.path.join(path, "sites", site_name, frappe.get_site_path('private', 'files', client.ca)[1:])
client_crt = os.path.join(path, "sites", site_name, frappe.get_site_path('private', 'files', client.client_crt)[1:])
client_key = os.path.join(path, "sites", site_name, frappe.get_site_path('private', 'files', client.client_key)[1:])
port_ssl = client.ssl_port
#frappe.msgprint(frappe.get_site_path('private', 'files', 'ca.crt').replace("./","/")
# connect to MQTT Broker to Publish Message
pid = os.getpid()
client_id = '{}:{}'.format('client', str(pid))
Expand Down

0 comments on commit d071139

Please sign in to comment.