|
# retoor <retoor@molodetz.nl>
|
|
|
|
CATEGORY_BY_PREFIX: dict[str, str] = {
|
|
"auth": "auth",
|
|
"profile": "account",
|
|
"follow": "social",
|
|
"push": "push",
|
|
"notification": "notification",
|
|
"message": "message",
|
|
"post": "content",
|
|
"comment": "content",
|
|
"gist": "content",
|
|
"issue": "content",
|
|
"vote": "engagement",
|
|
"reaction": "engagement",
|
|
"bookmark": "engagement",
|
|
"poll": "engagement",
|
|
"project": "project",
|
|
"file": "project_files",
|
|
"dir": "project_files",
|
|
"files": "project_files",
|
|
"job.zip": "project_files",
|
|
"job.backup": "backup",
|
|
"backup": "backup",
|
|
"attachment": "attachment",
|
|
"news": "news",
|
|
"admin": "admin",
|
|
"service": "service",
|
|
"container": "container",
|
|
"proxy": "ingress",
|
|
"seo": "tools",
|
|
"deepsearch": "tools",
|
|
"ai": "ai",
|
|
"database": "database",
|
|
"pubsub": "pubsub",
|
|
"devii": "devii",
|
|
"cli": "cli",
|
|
"reward": "reward",
|
|
"security": "security",
|
|
}
|
|
|
|
EVENT_RESULTS = ("success", "failure", "denied")
|
|
ACTOR_KINDS = ("user", "guest", "system", "cli", "service")
|
|
ORIGINS = ("web", "api", "devii", "cli", "service", "scheduler")
|
|
|
|
|
|
def category_for(event_key: str) -> str:
|
|
if not event_key:
|
|
return "other"
|
|
parts = event_key.split(".")
|
|
for size in range(len(parts), 0, -1):
|
|
prefix = ".".join(parts[:size])
|
|
if prefix in CATEGORY_BY_PREFIX:
|
|
return CATEGORY_BY_PREFIX[prefix]
|
|
return parts[0]
|