From 490792d64e86cc891900875c45087000fd50b579 Mon Sep 17 00:00:00 2001
From: sanj <67624670+iodrift@users.noreply.github.com>
Date: Mon, 12 Aug 2024 17:00:10 -0700
Subject: [PATCH] Auto-update: Mon Aug 12 17:00:10 PDT 2024

---
 sijapi/database.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sijapi/database.py b/sijapi/database.py
index 5783260..227af6a 100644
--- a/sijapi/database.py
+++ b/sijapi/database.py
@@ -408,13 +408,18 @@ class Database:
         for server in self.config['POOL']:
             if server['ts_id'] in online_servers and server['ts_id'] != self.local_ts_id:
                 url = f"http://{server['ts_ip']}:{server['app_port']}/db/sync"
-                tasks.append(self.call_db_sync(url))
+                tasks.append(self.call_db_sync(server))
         await asyncio.gather(*tasks)
 
-    async def call_db_sync(self, url):
+
+    async def call_db_sync(self, server):
+        url = f"http://{server['ts_ip']}:{server['app_port']}/db/sync"
+        headers = {
+            "Authorization": f"Bearer {server['api_key']}"
+        }
         async with aiohttp.ClientSession() as session:
             try:
-                async with session.post(url, timeout=30) as response:
+                async with session.post(url, headers=headers, timeout=30) as response:
                     if response.status == 200:
                         l.info(f"Successfully called /db/sync on {url}")
                     else:
@@ -424,6 +429,7 @@ class Database:
             except Exception as e:
                 l.error(f"Error calling /db/sync on {url}: {str(e)}")
 
+
     async def close(self):
         for engine in self.engines.values():
             await engine.dispose()