1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-04-27 19:15:07 +00:00

Get notification server url from env (#752)

Co-authored-by: Heran Yang <heran.yang@seafile.com>
This commit is contained in:
feiniks 2025-04-08 11:51:11 +08:00 committed by GitHub
parent 2a6ddc4851
commit 69932ee8ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 39 deletions

View File

@ -115,29 +115,10 @@ func LoadFileServerOptions(centralDir string) {
} }
} }
if section, err := config.GetSection("notification"); err == nil { notifServer := os.Getenv("NOTIFICATION_SERVER_URL")
if key, err := section.GetKey("enabled"); err == nil { if notifServer != "" {
EnableNotification, _ = key.Bool() NotificationURL = fmt.Sprintf("%s:8083", notifServer)
} EnableNotification = true
}
if EnableNotification {
var notifServer string
var notifPort uint32
if section, err := config.GetSection("notification"); err == nil {
if key, err := section.GetKey("host"); err == nil {
notifServer = key.String()
}
}
if section, err := config.GetSection("notification"); err == nil {
if key, err := section.GetKey("port"); err == nil {
port, err := key.Uint()
if err == nil {
notifPort = uint32(port)
}
}
}
NotificationURL = fmt.Sprintf("%s:%d", notifServer, notifPort)
} }
if section, err := config.GetSection("httpserver"); err == nil { if section, err := config.GetSection("httpserver"); err == nil {

View File

@ -110,7 +110,6 @@ load_config (SeafileSession *session, const char *config_file_path)
int ret = 0; int ret = 0;
GError *error = NULL; GError *error = NULL;
GKeyFile *config = NULL; GKeyFile *config = NULL;
gboolean notif_enabled = FALSE;
char *notif_server = NULL; char *notif_server = NULL;
int notif_port = 8083; int notif_port = 8083;
const char *private_key = NULL; const char *private_key = NULL;
@ -133,30 +132,18 @@ load_config (SeafileSession *session, const char *config_file_path)
session->obj_cache = objcache_new (); session->obj_cache = objcache_new ();
notif_enabled = g_key_file_get_boolean (config,
"notification", "enabled",
NULL);
if (notif_enabled) {
notif_server = g_key_file_get_string (config,
"notification", "host",
NULL);
notif_port = g_key_file_get_integer (config,
"notification", "port",
NULL);
}
// Read config from env // Read config from env
private_key = g_getenv("JWT_PRIVATE_KEY"); private_key = g_getenv("JWT_PRIVATE_KEY");
site_root = g_getenv("SITE_ROOT"); site_root = g_getenv("SITE_ROOT");
log_to_stdout = g_getenv("SEAFILE_LOG_TO_STDOUT"); log_to_stdout = g_getenv("SEAFILE_LOG_TO_STDOUT");
notif_server = g_getenv("NOTIFICATION_SERVER_URL");
if (!private_key) { if (!private_key) {
seaf_warning ("Failed to read JWT_PRIVATE_KEY.\n"); seaf_warning ("Failed to read JWT_PRIVATE_KEY.\n");
ret = -1; ret = -1;
goto out; goto out;
} }
if (notif_enabled && notif_server != NULL) { if (notif_server && g_strcmp0 (notif_server, "") != 0) {
session->notif_server_private_key = g_strdup (private_key); session->notif_server_private_key = g_strdup (private_key);
char notif_url[128]; char notif_url[128];
g_sprintf (notif_url, "%s:%d", notif_server, notif_port); g_sprintf (notif_url, "%s:%d", notif_server, notif_port);
@ -174,7 +161,6 @@ load_config (SeafileSession *session, const char *config_file_path)
} }
out: out:
g_free (notif_server);
if (ret < 0) { if (ret < 0) {
if (config) if (config)
g_key_file_free (config); g_key_file_free (config);