File tree Expand file tree Collapse file tree 4 files changed +27
-39
lines changed
Expand file tree Collapse file tree 4 files changed +27
-39
lines changed Original file line number Diff line number Diff line change 11# Package
22
3- version = " 0.4.0 "
3+ version = " 0.4.1 "
44author = " ThomasTJdev"
55description = " Newsletter"
66license = " AGPL v3"
Original file line number Diff line number Diff line change @@ -88,13 +88,11 @@ proc(request: Request) =
8888 if userID == " " :
8989 resp Http400 , " User not found"
9090
91- let mailID = getMailIDfromIdent (mail)
92- if mailID == " " :
93- resp Http400 , " Mail not found"
91+ let mailID = if mail == " " : " " else : getMailIDfromIdent (mail)
9492
9593 pg.withConnection conn:
9694 # For a specific mailID
97- if mail != " " :
95+ if mailID != " " :
9896 if getValue (conn, sqlSelect (
9997 table = " mails" ,
10098 select = [
Original file line number Diff line number Diff line change @@ -466,8 +466,6 @@ proc(request: Request) =
466466 listID = @ " listID"
467467 email = @ " email"
468468
469- echo email.isValidEmail ()
470-
471469 var
472470 mailData: seq [string ]
473471 contactData: seq [string ]
@@ -526,4 +524,6 @@ proc(request: Request) =
526524 elif listExists:
527525 createPendingEmailToAllListContacts (listID, mailID)
528526
527+ resp Http200 , " Mail sent to listID: " & listID
528+
529529)
Original file line number Diff line number Diff line change @@ -59,44 +59,34 @@ proc createPendingEmail*(
5959 " NULL"
6060 )
6161
62- let argsData = @ [
63- userID,
64- listID,
65- flowID,
66- flowStepID,
67- mailID,
68- triggerType,
69- status,
70- scheduledFor
71- ]
72-
73- var args = @ [
74- userID,
75- listID,
76- flowID,
77- flowStepID,
78- mailID,
79- triggerType,
80- status
81- ]
62+ var args = @ [userID]
63+ var data = @ [ " user_id " ]
64+ if listID != " " :
65+ data. add ( " list_id " )
66+ args. add (listID)
67+ if flowID != " " :
68+ data. add ( " flow_id " )
69+ args. add (flowID)
70+ if flowStepID != " " :
71+ data. add ( " flow_step_id " )
72+ args. add (flowStepID)
73+ if mailID != " " :
74+ data. add ( " mail_id " )
75+ args. add (mailID)
76+ if triggerType != " " :
77+ data. add ( " trigger_type " )
78+ args. add (triggerType)
79+ if status != " " :
80+ data. add ( " status" )
81+ args. add (status)
8282 if scheduledFor != " NULL" :
83+ data.add (" scheduled_for" )
8384 args.add (scheduledFor)
8485
8586 pg.withConnection conn:
86-
8787 exec (conn, sqlInsert (
8888 table = " pending_emails" ,
89- data = [
90- " user_id" ,
91- " list_id" ,
92- " flow_id" ,
93- " flow_step_id" ,
94- " mail_id" ,
95- " trigger_type" ,
96- " status" ,
97- " scheduled_for" ,
98- ],
99- args = argsData
89+ data = data,
10090 ), args)
10191
10292
You can’t perform that action at this time.
0 commit comments