testing out some model rewrites
All checks were successful
Build and Push Docker Image / build (push) Successful in 16s
All checks were successful
Build and Push Docker Image / build (push) Successful in 16s
This commit is contained in:
parent
b99ef216eb
commit
71b9b2f437
@ -413,4 +413,113 @@ class UniqueContentRule(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region Rewrite - - - - - - - -
|
||||
|
||||
|
||||
class _Server(models.Model):
|
||||
id = models.PositiveIntegerField(primary_key=True)
|
||||
name = models.CharField(max_length=128)
|
||||
icon_hash = models.CharField(max_length=128)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
@property
|
||||
def icon_url(self):
|
||||
return f"https://cdn.discordapp.com/icons/{self.id}/{self.icon_hash}.webp?size=80"
|
||||
|
||||
|
||||
class _Subscription(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
server = models.ForeignKey(to=_Server, on_delete=models.CASCADE)
|
||||
|
||||
name = models.CharField(max_length=32, blank=False)
|
||||
url = models.URLField()
|
||||
created_at = models.DateTimeField(default=timezone.now, editable=False)
|
||||
updated_at = models.DateTimeField(default=timezone.now)
|
||||
extra_notes = models.CharField(max_length=250, default="", blank=True)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
filters = models.ManyToManyField(to=_ContentFilter, blank=True)
|
||||
message_style = models.ForeignKey(to=_MessageStyle, blank=False)
|
||||
|
||||
|
||||
class _ContentFilter(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
server = models.ForeignKey(to=_Server)
|
||||
|
||||
MATCH_NONE = 0
|
||||
MATCH_ANY = 1
|
||||
MATCH_ALL = 2
|
||||
MATCH_LITERAL = 3
|
||||
MATCH_REGEX = 4
|
||||
MATCH_FUZZY = 5
|
||||
MATCH_AUTO = 6
|
||||
|
||||
MATCHING_ALGORITHMS = (
|
||||
(MATCH_NONE, _("None")),
|
||||
(MATCH_ANY, _("Any: Item contains any of these words (space separated)")),
|
||||
(MATCH_ALL, _("All: Item contains all of these words (space separated)")),
|
||||
(MATCH_LITERAL, _("Exact: Item contains this string")),
|
||||
(MATCH_REGEX, _("Regular expression: Item matches this regex")),
|
||||
(MATCH_FUZZY, _("Fuzzy: Item contains a word similar to this word")),
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=32)
|
||||
match = models.CharField(max_length=256, blank=False)
|
||||
matching_algorithm = models.PositiveIntegerField(choices=MATCHING_ALGORITHMS)
|
||||
is_insensitive = models.BooleanField()
|
||||
is_whitelist = models.BooleanField()
|
||||
|
||||
|
||||
class _Content(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
subscription = models.ForeignKey(to=_Subscription, on_delete=models.CASCADE)
|
||||
|
||||
# 'item_' prefix is to differentiate between the internal identifiers and the stored data
|
||||
item_id = models.CharField(max_length=1024)
|
||||
item_guid = models.CharField(max_length=1024)
|
||||
item_url = models.CharField(max_length=1024)
|
||||
item_title = models.CharField(max_length=1024)
|
||||
item_content_hash = models.CharField(max_length=1024)
|
||||
|
||||
|
||||
class _MessageStyle(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
server = models.ForeignKey(to=_Server, on_delete=models.CASCADE)
|
||||
|
||||
is_embed = models.BooleanField(default=True)
|
||||
is_hyperlinked = models.BooleanField() # title only
|
||||
show_author = models.BooleanField()
|
||||
show_timestamp = models.BooleanField()
|
||||
show_images = models.BooleanField()
|
||||
fetch_images = models.BooleanField() # if not included with RSS item
|
||||
|
||||
title_mutator = models.ForeignKey(to=_MessageMutator, on_delete=models.SET_NULL)
|
||||
description_mutator = models.ForeignKey(to=_MessageMutator, on_delete=models.SET_NULL)
|
||||
|
||||
|
||||
# Instances of this model are predefined only
|
||||
class _MessageMutator(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=64)
|
||||
value = models.CharField(max_length=32)
|
||||
|
||||
|
||||
# Instances of this model are predefined only
|
||||
class _UniqueContentRule(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=64)
|
||||
value = models.CharField(max_length=32)
|
||||
|
||||
|
||||
# Relevant logs from the bot logic
|
||||
class BotLogicLogs(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
server = models.ForeignKey(to=_Server, on_delete=models.CASCADE)
|
||||
|
||||
level = models.CharField()
|
||||
message = models.CharField() # todo
|
||||
created_at = models.DateTimeField(default=timezone.now, editable=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user