mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-07 00:20:37 +00:00
Merge branch 'master' into def/add_users_repositories
This commit is contained in:
commit
6fa8adca7c
|
@ -49,12 +49,13 @@ in
|
||||||
pkgs.kanidm
|
pkgs.kanidm
|
||||||
];
|
];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
wantedBy = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "root";
|
User = "root";
|
||||||
ExecStart = "${selfprivacy-graphql-api}/bin/app.py";
|
ExecStart = "${selfprivacy-graphql-api}/bin/app.py";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "5";
|
RestartSec = "5";
|
||||||
|
Slice = "selfprivacy_api.slice";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.services.selfprivacy-api-worker = {
|
systemd.services.selfprivacy-api-worker = {
|
||||||
|
@ -82,14 +83,19 @@ in
|
||||||
pkgs.iproute2
|
pkgs.iproute2
|
||||||
];
|
];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
wantedBy = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "root";
|
User = "root";
|
||||||
ExecStart = "${pkgs.python312Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey";
|
ExecStart = "${pkgs.python312Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "5";
|
RestartSec = "5";
|
||||||
|
Slice = "selfprivacy_api.slice";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
systemd.slices."selfprivacy_api" = {
|
||||||
|
name = "selfprivacy_api.slice";
|
||||||
|
description = "Slice for SelfPrivacy API services";
|
||||||
|
};
|
||||||
# One shot systemd service to rebuild NixOS using nixos-rebuild
|
# One shot systemd service to rebuild NixOS using nixos-rebuild
|
||||||
systemd.services.sp-nixos-rebuild = {
|
systemd.services.sp-nixos-rebuild = {
|
||||||
description = "nixos-rebuild switch";
|
description = "nixos-rebuild switch";
|
||||||
|
|
|
@ -27,4 +27,4 @@ async def get_token_header(
|
||||||
|
|
||||||
def get_api_version() -> str:
|
def get_api_version() -> str:
|
||||||
"""Get API version"""
|
"""Get API version"""
|
||||||
return "3.3.0"
|
return "3.4.0"
|
||||||
|
|
|
@ -21,11 +21,17 @@ async def log_stream() -> AsyncGenerator[LogEntry, None]:
|
||||||
|
|
||||||
asyncio.get_event_loop().add_reader(j, lambda: asyncio.ensure_future(callback()))
|
asyncio.get_event_loop().add_reader(j, lambda: asyncio.ensure_future(callback()))
|
||||||
|
|
||||||
while True:
|
try:
|
||||||
entry = await queue.get()
|
while True:
|
||||||
try:
|
entry = await queue.get()
|
||||||
yield LogEntry(entry)
|
try:
|
||||||
except Exception:
|
yield LogEntry(entry)
|
||||||
asyncio.get_event_loop().remove_reader(j)
|
except Exception:
|
||||||
return
|
asyncio.get_event_loop().remove_reader(j)
|
||||||
queue.task_done()
|
j.close()
|
||||||
|
return
|
||||||
|
queue.task_done()
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
asyncio.get_event_loop().remove_reader(j)
|
||||||
|
j.close()
|
||||||
|
return
|
||||||
|
|
|
@ -88,7 +88,7 @@ class ServiceManager(Service):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id() -> str:
|
def get_id() -> str:
|
||||||
"""Return service id."""
|
"""Return service id."""
|
||||||
return "api"
|
return "selfprivacy-api"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_display_name() -> str:
|
def get_display_name() -> str:
|
||||||
|
@ -98,7 +98,7 @@ class ServiceManager(Service):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_description() -> str:
|
def get_description() -> str:
|
||||||
"""Return service description."""
|
"""Return service description."""
|
||||||
return "A proto-service for API itself. Currently manages backups of settings."
|
return "Enables communication between the SelfPrivacy app and the server."
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_svg_icon() -> str:
|
def get_svg_icon() -> str:
|
||||||
|
@ -135,7 +135,7 @@ class ServiceManager(Service):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_backup_description() -> str:
|
def get_backup_description() -> str:
|
||||||
return "How did we get here?"
|
return "General server settings."
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_status(cls) -> ServiceStatus:
|
def get_status(cls) -> ServiceStatus:
|
||||||
|
|
|
@ -10,6 +10,7 @@ from selfprivacy_api.services.service import Service, ServiceStatus
|
||||||
from selfprivacy_api.services.nextcloud.icon import NEXTCLOUD_ICON
|
from selfprivacy_api.services.nextcloud.icon import NEXTCLOUD_ICON
|
||||||
from selfprivacy_api.services.config_item import (
|
from selfprivacy_api.services.config_item import (
|
||||||
StringServiceConfigItem,
|
StringServiceConfigItem,
|
||||||
|
BoolServiceConfigItem,
|
||||||
ServiceConfigItem,
|
ServiceConfigItem,
|
||||||
)
|
)
|
||||||
from selfprivacy_api.utils.regex_strings import SUBDOMAIN_REGEX
|
from selfprivacy_api.utils.regex_strings import SUBDOMAIN_REGEX
|
||||||
|
@ -26,6 +27,11 @@ class Nextcloud(Service):
|
||||||
regex=SUBDOMAIN_REGEX,
|
regex=SUBDOMAIN_REGEX,
|
||||||
widget="subdomain",
|
widget="subdomain",
|
||||||
),
|
),
|
||||||
|
"enableImagemagick": BoolServiceConfigItem(
|
||||||
|
id="enableImagemagick",
|
||||||
|
default_value=True,
|
||||||
|
description="Enable ImageMagick",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -42,6 +42,8 @@ def get_paginated_logs(
|
||||||
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
||||||
events.reverse()
|
events.reverse()
|
||||||
|
|
||||||
|
j.close()
|
||||||
|
|
||||||
return events
|
return events
|
||||||
elif up_cursor is None and down_cursor is not None:
|
elif up_cursor is None and down_cursor is not None:
|
||||||
j.seek_cursor(down_cursor)
|
j.seek_cursor(down_cursor)
|
||||||
|
@ -50,6 +52,8 @@ def get_paginated_logs(
|
||||||
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
events = get_events_from_journal(j, limit, lambda j: j.get_previous())
|
||||||
events.reverse()
|
events.reverse()
|
||||||
|
|
||||||
|
j.close()
|
||||||
|
|
||||||
return events
|
return events
|
||||||
elif up_cursor is not None and down_cursor is None:
|
elif up_cursor is not None and down_cursor is None:
|
||||||
j.seek_cursor(up_cursor)
|
j.seek_cursor(up_cursor)
|
||||||
|
@ -57,8 +61,12 @@ def get_paginated_logs(
|
||||||
|
|
||||||
events = get_events_from_journal(j, limit, lambda j: j.get_next())
|
events = get_events_from_journal(j, limit, lambda j: j.get_next())
|
||||||
|
|
||||||
|
j.close()
|
||||||
|
|
||||||
return events
|
return events
|
||||||
else:
|
else:
|
||||||
|
j.close()
|
||||||
|
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"Pagination by both up_cursor and down_cursor is not implemented"
|
"Pagination by both up_cursor and down_cursor is not implemented"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue