mailboxes ratelimit and groups

This commit is contained in:
Jorge Pastor 2024-07-09 17:36:32 +02:00
parent 67c291cb99
commit e15d2acd13

View file

@ -679,29 +679,23 @@ class RSpamdRatelimitController(ServiceController):
def save(self, mailbox): def save(self, mailbox):
context = self.get_context(mailbox) context = self.get_context(mailbox)
self.append(textwrap.dedent(""" self.append(textwrap.dedent("""
# sed -i '/^%(user)s$/d' %(maps)s sed -i '/^%(user)s$/d' %(maps)s
# echo '%(user)s' >> %(path_maps)s%(ratelimit)s.map echo '%(user)s' >> %(path_maps)s%(ratelimit)s.map
if ! grep -qx '%(user)s' /etc/rspamd/local.d/maps/usuariosbase.map; then systemctl reload rspamd.service
echo '%(user)s' >> /etc/rspamd/local.d/maps/usuariosbase.map
RELOAD_RSPAMD=1
fi
""") % context """) % context
) )
def delete(self, mailbox): def delete(self, mailbox):
context = self.get_context(mailbox) context = self.get_context(mailbox)
self.append(textwrap.dedent(""" self.append(textwrap.dedent("""
# sed -i '/^%(user)s$/d' %(maps)s sed -i '/^%(user)s$/d' %(maps)s
if grep -qx '%(user)s' /etc/rspamd/local.d/maps/usuariosbase.map; then systemctl reload rspamd.service
sed -i '/^%(user)s$/d' /etc/rspamd/local.d/maps/usuariosbase.map
RELOAD_RSPAMD=1
fi
""") % context """) % context
) )
def commit(self): # def commit(self):
self.append('# [[ $RELOAD_RSPAMD -eq 1 ]] && systemctl reload rspamd.service') # self.append('[[ $RELOAD_RSPAMD -eq 1 ]] && systemctl reload rspamd.service')
super().commit() # super().commit()
def get_context(self, mailbox): def get_context(self, mailbox):
maps = self.extract_group_maps() maps = self.extract_group_maps()