Skip to content

Commit 9fcce75

Browse files
committed
worker now writes in output/
1 parent cd8626b commit 9fcce75

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
secrets/
33
*/venv/
44
coverage/
5+
worker/output/
56

67
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
78

worker/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,24 @@ def callback(message):
106106
private_key = load_private_key(PRIVATE_KEY_PATH)
107107
decrypted_bytes = decrypt_data(json.dumps(inner_payload), private_key)
108108

109+
# create output directory if it doesn't exist
110+
if not os.path.exists('output'):
111+
os.makedirs('output')
112+
109113
if decrypted_bytes:
110114
print(f"--- NEW {note_type.upper()} NOTE ---")
111115
if note_type == 'text':
112116
print(f"Content: {decrypted_bytes.decode('utf-8')}")
117+
# save to file
118+
filename = f"output/received_text_{int(time.time())}.txt"
119+
with open(filename, "wb") as f:
120+
f.write(decrypted_bytes)
121+
print(f"Saved text to {filename}")
113122
elif note_type == 'audio':
114123
# Audio is base64 encoded inside the encrypted data
115124
audio_b64 = decrypted_bytes.decode('utf-8')
116125
audio_bytes = base64.b64decode(audio_b64)
117-
filename = f"received_audio_{int(time.time())}.m4a"
126+
filename = f"output/received_audio_{int(time.time())}.m4a"
118127
with open(filename, "wb") as f:
119128
f.write(audio_bytes)
120129
print(f"Saved audio to {filename}")

0 commit comments

Comments
 (0)