Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

50 lines
1.8 KiB
Python

import json
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.signals import post_delete, post_save
from django.dispatch.dispatcher import receiver
from insights.models.signals import mutable_receiver
from insights.models.utils import generate_random_token
from insights.redis import get_client
HOOK_EVENTS = ["action_performed"]
class Hook(models.Model):
id = models.CharField(primary_key=True, max_length=50, default=generate_random_token)
user = models.ForeignKey("insights.User", related_name="rest_hooks", on_delete=models.CASCADE)
team = models.ForeignKey("insights.Team", related_name="rest_hooks", on_delete=models.CASCADE)
event = models.CharField("Event", max_length=64, db_index=True)
resource_id = models.IntegerField(null=True, blank=True)
target = models.URLField("Target URL", max_length=255)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Meta:
db_table = "ee_hook"
def clean(self):
"""Validation for events."""
if self.event not in HOOK_EVENTS:
raise ValidationError("Invalid hook event {evt}.".format(evt=self.event))
@receiver(post_save, sender=Hook)
def hook_saved(sender, instance: Hook, created, **kwargs):
if instance.event == "action_performed":
get_client().publish(
"reload-action",
json.dumps({"teamId": instance.team_id, "actionId": instance.resource_id}),
)
@mutable_receiver(post_delete, sender=Hook)
def hook_deleted(sender, instance: Hook, **kwargs):
if instance.event == "action_performed":
get_client().publish(
"drop-action",
json.dumps({"teamId": instance.team_id, "actionId": instance.resource_id}),
)