Avoid adding lists to project multiple times

If a list exists already it might also already be connected to the
project. If that is the case, simply skip processing this list.

Fixes: https://todo.sr.ht/~sircmpwn/hub.sr.ht/83
This commit is contained in:
Conrad Hoffmann 2022-03-14 12:38:36 +01:00 committed by Drew DeVault
parent 38292b8bea
commit d52edefe18
1 changed files with 5 additions and 0 deletions

View File

@ -95,6 +95,11 @@ Mailing list for end-user discussion and questions related to the
list_name = list_name.lower() # Per lists.sr.ht naming rules
try:
mailing_list = lists.get_list(owner, list_name)
in_project = [l.remote_id for l in (MailingList.query
.filter(MailingList.project_id == project.id)
.filter(MailingList.name == list_name)).all()]
if in_project:
continue
except:
valid = Validation({
"name": list_name,