generated from ITwrxOrg/EZ-Bkup
make hardcoded values release friendly
This commit is contained in:
@@ -69,12 +69,10 @@ proc nextMonthlyOnWeekdayOfWeek*(weekdayString: string, ocurrence: string): Date
|
||||
let nextMonthsDate = now() + 1.months
|
||||
let weekNumStrings = @["1", "2", "3"]
|
||||
if ocurrence in weekNumStrings:
|
||||
#nextSendDate = nthWeekdayInMonth(year(nextMonthsDate), month(now()), weekdayString, parseInt(ocurrence))
|
||||
nextSendDate = nthWeekdayInMonth(year(now()), month(now()), weekdayString, parseInt(ocurrence))
|
||||
if format(nextSendDate, "yyyy-MM-dd") <= format(now(), "yyyy-MM-dd"):
|
||||
nextSendDate = nthWeekdayInMonth(year(nextMonthsDate), month(nextMonthsDate), weekdayString, parseInt(ocurrence))
|
||||
else:
|
||||
#nextSendDate = lastWeekdayInMonth(year(nextMonthsDate), month(now()), weekdayString)
|
||||
nextSendDate = lastWeekdayInMonth(year(now()), month(now()), weekdayString)
|
||||
if format(nextSendDate, "yyyy-MM-dd") <= format(now(), "yyyy-MM-dd"):
|
||||
nextSendDate = lastWeekdayInMonth(year(nextMonthsDate), month(nextMonthsDate), weekdayString)
|
||||
|
||||
@@ -7,22 +7,21 @@ import std/[times, strutils, re, uri, paths, random, strtabs]
|
||||
|
||||
#universal
|
||||
const APP_PATH* = "/var/www/forget-me-not-gs"
|
||||
const ASSETS_PATH* = "/var/www/forget-me-not-gs/app/assets"
|
||||
const ASSETS_PATH* = "/var/www/forget-me-not-gs/assets"
|
||||
const APP_NAME* = "Forget-Me-Not"
|
||||
#set to 'dev' or 'prod'
|
||||
#set to 'dev' or 'prod'. changes how cookies are created and possibly paths, if using two environments. Maybe other stuff i'm forgetting.
|
||||
const APP_MODE* = "dev"
|
||||
#dev
|
||||
#using paths config'd in /etc/hosts for local dev.
|
||||
const APP_URL* = "http://fmn-gs"
|
||||
#const SITE_URL* = "http://"
|
||||
const ASSETS_URL* = "http://assets.fmn-gs"
|
||||
#prod
|
||||
#const APP_URL* = "https://ssm.itwrx.org"
|
||||
#const SITE_URL* = "https://itwrx.org"
|
||||
#const ASSETS_URL* = "https://assets.itwrx.org"
|
||||
#const APP_URL* = "https://my-fmn-url.com"
|
||||
#const ASSETS_URL* = "https://assets.my-fmn-url.com"
|
||||
|
||||
var frStrTab* = newStringTable()
|
||||
|
||||
#TODO: implement logging or remove logging code.
|
||||
#TODO: implement logging or remove logging code. Remove SSM code not used in FMN.
|
||||
|
||||
#Guildensterns logger is conflicting with my, evidently incorrect, usage of the std lib logger so i'll just write some lines to a file for now.
|
||||
#var logger* = newFileLogger("errors.log")
|
||||
|
||||
@@ -6,6 +6,8 @@ See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
import std/[times, osproc], smtp
|
||||
import ../models/reminder, ../models/user, datetime
|
||||
|
||||
#TODO: use comnfig file for creds and other comms settings instead of hardcoding.
|
||||
|
||||
proc setFutureSendDate(reminderId: int) =
|
||||
var reminder: Reminder
|
||||
reminder = getReminderById(reminderId)
|
||||
@@ -53,23 +55,24 @@ proc setFutureSendDate(reminderId: int) =
|
||||
echo "Invalid value for reminder.repeatFreq in setFutureSendDate()"
|
||||
|
||||
proc sendEmail(reminderMsg: string) =
|
||||
##Warning: hardcoded userId expects one user with id of 1.
|
||||
let userEmailAddress = getEmailByUserId("1")
|
||||
let headers = @[("From", "mailer@itwrx.org")]
|
||||
let headers = @[("From", "mymaileraccount@mydomain.org")]
|
||||
let msg = createMessage("Reminder from Forget-Me-Not", reminderMsg, @[userEmailAddress], mCc = @[""], otherHeaders = headers)
|
||||
{.cast(raises: []).}:
|
||||
let smtpConn = newSmtp(debug=false)
|
||||
smtpConn.connect("email.itwrx.org", Port 587)
|
||||
smtpConn.connect("mail.mydomain.org", Port 587)
|
||||
smtpConn.startTls()
|
||||
smtpConn.auth("mailer@itwrx.org", ".AQ8u((xB(AgZh^a`jEJ~W~{0Eq?fd$")
|
||||
smtpConn.auth("mymaileraccount@mydomain.org", "mymaileraccount-password-goes-here")
|
||||
#loop through email messages and send to reuse connection?
|
||||
smtpConn.sendmail("mailer@itwrx.org", @[userEmailAddress], $msg)
|
||||
smtpConn.sendmail("mymaileraccount@mydomain.org", @[userEmailAddress], $msg)
|
||||
#manually closing not necessary?
|
||||
smtpConn.close()
|
||||
|
||||
proc sendXMPP(reminderMsg: string) =
|
||||
var output: string
|
||||
var status: int
|
||||
(output, status) = execCmdEx("xmppc -m message chat itwrx@sec-chat.itwrx.org \"" & reminderMsg & "\"")
|
||||
(output, status) = execCmdEx("xmppc -m message chat receiving-xmpp-user@myxmppserverdomain.org \"" & reminderMsg & "\"")
|
||||
if status != 0:
|
||||
#log this later instead.
|
||||
echo output
|
||||
|
||||
Reference in New Issue
Block a user