Skip to content

Commit

Permalink
add migration code
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Mar 28, 2024
1 parent 0af0261 commit 6f207a2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions authentik/events/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class LogEventSerializer(PassiveSerializer):
event = CharField()
attributes = DictField()

# TODO(2024.6?): This is a migration helper to return a correct API response for logs that
# have been saved in an older format (mostly just list[str] with just the messages)
def to_representation(self, instance):
if isinstance(instance, str):
instance = LogEvent(instance, "", "")
elif isinstance(instance, list):
instance = [LogEvent(x, "", "") for x in instance]
return super().to_representation(instance)


@contextmanager
def capture_logs(log_default_output=True) -> Generator[list[LogEvent], None, None]:
Expand Down

0 comments on commit 6f207a2

Please sign in to comment.