feat: ability to turn off logs for admins users
This commit is contained in:
@@ -212,6 +212,7 @@ LOG_PAYMENTS=True #
|
|||||||
LOG_PROMO_ACTIVATIONS=True # Log promo code activations
|
LOG_PROMO_ACTIVATIONS=True # Log promo code activations
|
||||||
LOG_TRIAL_ACTIVATIONS=True # Log trial activations
|
LOG_TRIAL_ACTIVATIONS=True # Log trial activations
|
||||||
LOG_SUSPICIOUS_ACTIVITY=True # Log suspicious activity
|
LOG_SUSPICIOUS_ACTIVITY=True # Log suspicious activity
|
||||||
|
LOG_ADMIN_ACTIONS=True # Log actions from users listed in ADMIN_IDS
|
||||||
|
|
||||||
# Embedded mode thumbnails. Please don't touch this if you don't know what it is.
|
# Embedded mode thumbnails. Please don't touch this if you don't know what it is.
|
||||||
INLINE_REFERRAL_THUMBNAIL_URL=https://cdn-icons-png.flaticon.com/512/1077/1077114.png
|
INLINE_REFERRAL_THUMBNAIL_URL=https://cdn-icons-png.flaticon.com/512/1077/1077114.png
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class SettingField:
|
|||||||
max: Optional[float] = None
|
max: Optional[float] = None
|
||||||
choices: Optional[Tuple[Tuple[str, str], ...]] = None
|
choices: Optional[Tuple[Tuple[str, str], ...]] = None
|
||||||
subsection: Optional[str] = None # group label inside a section
|
subsection: Optional[str] = None # group label inside a section
|
||||||
|
i18n_label_key: Optional[str] = None
|
||||||
|
i18n_description_key: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
SETTINGS_MANIFEST: List[SettingField] = [
|
SETTINGS_MANIFEST: List[SettingField] = [
|
||||||
@@ -165,6 +167,15 @@ SETTINGS_MANIFEST: List[SettingField] = [
|
|||||||
SettingField("LOG_PROMO_ACTIVATIONS", "bool", "notifications", "Логировать активации промокодов"),
|
SettingField("LOG_PROMO_ACTIVATIONS", "bool", "notifications", "Логировать активации промокодов"),
|
||||||
SettingField("LOG_TRIAL_ACTIVATIONS", "bool", "notifications", "Логировать активации триала"),
|
SettingField("LOG_TRIAL_ACTIVATIONS", "bool", "notifications", "Логировать активации триала"),
|
||||||
SettingField("LOG_SUSPICIOUS_ACTIVITY", "bool", "notifications", "Логировать подозрительные действия"),
|
SettingField("LOG_SUSPICIOUS_ACTIVITY", "bool", "notifications", "Логировать подозрительные действия"),
|
||||||
|
SettingField(
|
||||||
|
"LOG_ADMIN_ACTIONS",
|
||||||
|
"bool",
|
||||||
|
"notifications",
|
||||||
|
"Логировать действия администраторов",
|
||||||
|
"Если выключено, события от пользователей из ADMIN_IDS не записываются в message logs.",
|
||||||
|
i18n_label_key="admin_settings_field_log_admin_actions_label",
|
||||||
|
i18n_description_key="admin_settings_field_log_admin_actions_description",
|
||||||
|
),
|
||||||
SettingField("LOG_LEVEL", "string", "notifications", "Глобальный уровень логов", "DEBUG / INFO / WARNING / ERROR"),
|
SettingField("LOG_LEVEL", "string", "notifications", "Глобальный уровень логов", "DEBUG / INFO / WARNING / ERROR"),
|
||||||
SettingField("LOG_CHAT_ID", "int", "notifications", "ID чата для логов"),
|
SettingField("LOG_CHAT_ID", "int", "notifications", "ID чата для логов"),
|
||||||
SettingField("LOG_THREAD_ID", "int", "notifications", "ID треда (для супергрупп)"),
|
SettingField("LOG_THREAD_ID", "int", "notifications", "ID треда (для супергрупп)"),
|
||||||
@@ -253,6 +264,8 @@ def manifest_payload() -> List[dict]:
|
|||||||
"subsection": field.subsection,
|
"subsection": field.subsection,
|
||||||
"label": field.label,
|
"label": field.label,
|
||||||
"description": field.description,
|
"description": field.description,
|
||||||
|
"i18n_label_key": field.i18n_label_key,
|
||||||
|
"i18n_description_key": field.i18n_description_key,
|
||||||
"placeholder": field.placeholder,
|
"placeholder": field.placeholder,
|
||||||
"optional": field.optional,
|
"optional": field.optional,
|
||||||
"secret": field.secret,
|
"secret": field.secret,
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
<div class="admin-setting" class:is-overridden={isOverridden(field)}>
|
<div class="admin-setting" class:is-overridden={isOverridden(field)}>
|
||||||
<div class="admin-setting-meta">
|
<div class="admin-setting-meta">
|
||||||
<strong>
|
<strong>
|
||||||
{field.label}
|
{field.i18n_label_key ? at(field.i18n_label_key, {}, field.label) : field.label}
|
||||||
<AdminBadge variant="warning">{at("settings_badge_secret", {}, "Secret")}</AdminBadge>
|
<AdminBadge variant="warning">{at("settings_badge_secret", {}, "Secret")}</AdminBadge>
|
||||||
{#if isOverridden(field)}
|
{#if isOverridden(field)}
|
||||||
<AdminBadge variant="success">{at("settings_badge_override", {}, "Override")}</AdminBadge>
|
<AdminBadge variant="success">{at("settings_badge_override", {}, "Override")}</AdminBadge>
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
</strong>
|
</strong>
|
||||||
<code>{field.key}</code>
|
<code>{field.key}</code>
|
||||||
{#if field.description}
|
{#if field.description}
|
||||||
<small>{field.description}</small>
|
<small>{field.i18n_description_key ? at(field.i18n_description_key, {}, field.description) : field.description}</small>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="admin-setting-control">
|
<div class="admin-setting-control">
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class ActionLoggerMiddleware(BaseMiddleware):
|
|||||||
if user_id in self.settings.ADMIN_IDS:
|
if user_id in self.settings.ADMIN_IDS:
|
||||||
is_admin_event_flag = True
|
is_admin_event_flag = True
|
||||||
|
|
||||||
|
if is_admin_event_flag and not self.settings.LOG_ADMIN_ACTIONS:
|
||||||
|
return result
|
||||||
|
|
||||||
raw_update_snippet = None
|
raw_update_snippet = None
|
||||||
try:
|
try:
|
||||||
raw_update_snippet = event.model_dump_json(exclude_none=True,
|
raw_update_snippet = event.model_dump_json(exclude_none=True,
|
||||||
|
|||||||
@@ -383,6 +383,10 @@ class Settings(BaseSettings):
|
|||||||
)
|
)
|
||||||
|
|
||||||
LOGS_PAGE_SIZE: int = Field(default=10)
|
LOGS_PAGE_SIZE: int = Field(default=10)
|
||||||
|
LOG_ADMIN_ACTIONS: bool = Field(
|
||||||
|
default=True,
|
||||||
|
description="Log updates/events triggered by users from ADMIN_IDS.",
|
||||||
|
)
|
||||||
|
|
||||||
SUBSCRIPTION_MINI_APP_URL: Optional[str] = Field(default=None)
|
SUBSCRIPTION_MINI_APP_URL: Optional[str] = Field(default=None)
|
||||||
|
|
||||||
|
|||||||
@@ -1106,6 +1106,8 @@
|
|||||||
"admin_settings_params_count": "{count} parameters",
|
"admin_settings_params_count": "{count} parameters",
|
||||||
"admin_settings_overridden_count": "{count} override",
|
"admin_settings_overridden_count": "{count} override",
|
||||||
"admin_settings_fields_count": "{count} fields",
|
"admin_settings_fields_count": "{count} fields",
|
||||||
|
"admin_settings_field_log_admin_actions_label": "Log administrator actions",
|
||||||
|
"admin_settings_field_log_admin_actions_description": "When disabled, events from users listed in ADMIN_IDS are not stored in message logs.",
|
||||||
"admin_show": "Show",
|
"admin_show": "Show",
|
||||||
"admin_hide": "Hide",
|
"admin_hide": "Hide",
|
||||||
"admin_tariffs_stat_total": "Total tariffs",
|
"admin_tariffs_stat_total": "Total tariffs",
|
||||||
|
|||||||
@@ -1106,6 +1106,8 @@
|
|||||||
"admin_settings_params_count": "{count} параметров",
|
"admin_settings_params_count": "{count} параметров",
|
||||||
"admin_settings_overridden_count": "{count} override",
|
"admin_settings_overridden_count": "{count} override",
|
||||||
"admin_settings_fields_count": "{count} полей",
|
"admin_settings_fields_count": "{count} полей",
|
||||||
|
"admin_settings_field_log_admin_actions_label": "Логировать действия администраторов",
|
||||||
|
"admin_settings_field_log_admin_actions_description": "Если выключено, события от пользователей из ADMIN_IDS не записываются в message logs.",
|
||||||
"admin_show": "Показать",
|
"admin_show": "Показать",
|
||||||
"admin_hide": "Скрыть",
|
"admin_hide": "Скрыть",
|
||||||
"admin_tariffs_stat_total": "Всего тарифов",
|
"admin_tariffs_stat_total": "Всего тарифов",
|
||||||
|
|||||||
Reference in New Issue
Block a user