[fusion] Weekly backup 2026-07-10 — 7 files changed, 139 insertions(+), 2 deletions(-)

This commit is contained in:
FusionPBX Backup
2026-07-10 16:21:51 +00:00
parent 68af10b466
commit 42422975e4
7 changed files with 139 additions and 2 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
import sys, os, smtplib, subprocess
from email.message import EmailMessage
from datetime import datetime
GMAIL_USER = "myronblair@gmail.com"
GMAIL_PASS = "demsvdylwweacbcx"
def main():
if len(sys.argv) < 4:
print("usage: fax-to-email.py <tiff_path> <to_email> <caller_id>")
sys.exit(1)
tiff_path = sys.argv[1]
to_email = sys.argv[2]
caller_id = sys.argv[3]
if not os.path.exists(tiff_path):
print(f"tiff not found: {tiff_path}")
sys.exit(1)
pdf_path = tiff_path.rsplit(".", 1)[0] + ".pdf"
subprocess.run(["tiff2pdf", "-o", pdf_path, tiff_path], check=True)
msg = EmailMessage()
msg["Subject"] = f"Fax received from {caller_id} - {datetime.now().strftime('%Y-%m-%d %H:%M')}"
msg["From"] = GMAIL_USER
msg["To"] = to_email
msg.set_content(f"You received a fax from {caller_id}. See attached PDF.")
with open(pdf_path, "rb") as f:
msg.add_attachment(f.read(), maintype="application", subtype="pdf",
filename=os.path.basename(pdf_path))
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as s:
s.login(GMAIL_USER, GMAIL_PASS)
s.send_message(msg)
print(f"Sent fax email to {to_email}")
if __name__ == "__main__":
main()
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
import subprocess
import logging
from signalwire.relay.consumer import Consumer
PROJECT = "16fbbcfd-1c94-4827-869c-0364f5f67488"
TOKEN = "PTfb129c5160af67841e2da19d5e9d94bcf6312a81fa43f248"
CONTEXT = "Texting for Fusion"
FUSION_DOMAIN = "fusion.orbishosting.com"
TARGET_EXT = "1001"
logging.basicConfig(level="INFO")
log = logging.getLogger("sms-inbound")
class TextConsumer(Consumer):
def setup(self):
self.project = PROJECT
self.token = TOKEN
self.contexts = [CONTEXT]
def ready(self):
log.info(f"Connected to SignalWire Relay, listening on context: {self.contexts}")
def on_incoming_message(self, message):
from_num = message.from_number
body = message.body or ""
log.info(f"Inbound SMS from {from_num}: {body}")
deliver_to_phone(from_num, body)
def deliver_to_phone(from_num, body):
safe_body = body.replace('"', "'").replace("\n", " ")
chat_line = f"sip|{from_num}@{FUSION_DOMAIN}|internal/{TARGET_EXT}@{FUSION_DOMAIN}|{safe_body}"
result = subprocess.run(
["fs_cli", "-x", f"chat {chat_line}"],
capture_output=True, text=True
)
log.info(f"fs_cli chat delivery result: {result.stdout.strip()} {result.stderr.strip()}")
if __name__ == "__main__":
consumer = TextConsumer()
consumer.run()
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
import sys
import json
import urllib.request
import base64
PROJECT_ID = "16fbbcfd-1c94-4827-869c-0364f5f67488"
API_TOKEN = "PTfb129c5160af67841e2da19d5e9d94bcf6312a81fa43f248"
SPACE = "orbis-hosting.signalwire.com"
FROM_NUMBER = "+18177645007"
def send(to_number, body):
url = f"https://{SPACE}/api/messaging/messages"
payload = json.dumps({"to": to_number, "from": FROM_NUMBER, "body": body}).encode()
auth = base64.b64encode(f"{PROJECT_ID}:{API_TOKEN}".encode()).decode()
req = urllib.request.Request(url, data=payload, method="POST", headers={
"Content-Type": "application/json",
"Authorization": f"Basic {auth}",
})
try:
with urllib.request.urlopen(req) as resp:
print(resp.read().decode())
except urllib.error.HTTPError as e:
print(f"HTTP {e.code}: {e.read().decode()}")
sys.exit(1)
def main():
if len(sys.argv) < 3:
print("usage: sms-outbound-send.py <to_number> <body>")
sys.exit(1)
send(sys.argv[1], sys.argv[2])
if __name__ == "__main__":
main()