mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -126,6 +126,9 @@ class SQLWrapper(object):
|
||||
rq &= doms_q
|
||||
return len(Msgrcpt.objects.filter(rq))
|
||||
|
||||
def get_mail_content(self, mailid):
|
||||
return Quarantine.objects.filter(mail=mail_id)
|
||||
|
||||
class PgWrapper(SQLWrapper):
|
||||
|
||||
def get_mails(self, request, rcptfilter=None):
|
||||
@@ -149,10 +152,11 @@ class PgWrapper(SQLWrapper):
|
||||
return Msgrcpt.objects.filter(q).extra(where=where, tables=['maddr']).values("mail_id")
|
||||
|
||||
def get_recipient_message(self, address, mailid):
|
||||
return Msgrcpt.objects.filter(mail=mailid).extra(
|
||||
qset = Msgrcpt.objects.filter(mail=mailid).extra(
|
||||
where=["convert_from(maddr.email, 'UTF8') = '%s'" % address],
|
||||
tables=['maddr']
|
||||
)
|
||||
return qset.all()[0]
|
||||
|
||||
def get_recipient_messages(self, address, mailids):
|
||||
return Msgrcpt.objects.filter(mail__in=mailids).extra(
|
||||
@@ -175,6 +179,12 @@ class PgWrapper(SQLWrapper):
|
||||
return len(Msgrcpt.objects.filter(rq).extra(where=["convert_from(maddr.email, 'UTF8') ~ '%s'" % (regexp,)], tables=['maddr']))
|
||||
return len(Msgrcpt.objects.filter(rq))
|
||||
|
||||
|
||||
def get_mail_content(self, mailid):
|
||||
return Quarantine.objects.filter(mail=mailid).extra(
|
||||
select={'mail_text' : "convert_from(mail_text, 'UTF8'"}
|
||||
)
|
||||
|
||||
def get_wrapper():
|
||||
if db_type() == 'postgres':
|
||||
return PgWrapper()
|
||||
|
||||
@@ -99,7 +99,7 @@ def index(request):
|
||||
def getmailcontent_selfservice(request, mail_id):
|
||||
from sql_listing import SQLemail
|
||||
|
||||
qmails = Quarantine.objects.filter(mail=mail_id)
|
||||
qmails = get_wrapper().get_mail_content(mail_id)
|
||||
content = ""
|
||||
for qm in qmails:
|
||||
content += qm.mail_text
|
||||
@@ -114,7 +114,7 @@ def getmailcontent_selfservice(request, mail_id):
|
||||
def getmailcontent(request, mail_id):
|
||||
from sql_listing import SQLemail
|
||||
|
||||
qmails = Quarantine.objects.filter(mail=mail_id)
|
||||
qmails = get_wrapper().get_mail_content(mail_id)
|
||||
content = ""
|
||||
for qm in qmails:
|
||||
content += qm.mail_text
|
||||
|
||||
Reference in New Issue
Block a user