16 lines
399 B
Python
16 lines
399 B
Python
|
import json
|
||
|
from datetime import datetime, timedelta
|
||
|
|
||
|
from aurora.models import Moderation
|
||
|
|
||
|
|
||
|
class JSONEncoder(json.JSONEncoder):
|
||
|
def default(self, o):
|
||
|
if isinstance(o, datetime):
|
||
|
return int(o.timestamp())
|
||
|
if isinstance(o, timedelta):
|
||
|
return str(o)
|
||
|
if isinstance(o, Moderation):
|
||
|
return o.model_dump()
|
||
|
return super().default(o)
|