-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrvEmail.R
103 lines (99 loc) · 3.99 KB
/
srvEmail.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# functions for sending email reminders
# last update: 2017-02-06
writeSchedulerEmail <- function(app, app_name, email, subject, content, time, response_structure, id){
port <- as.character(session$clientData$url_port)
url <- paste0(session$clientData$url_protocol, '//',
session$clientData$url_hostname)
if(port == '80'){
app_url <- url
} else {
app_url <- paste0(url, ':', port)
}
if(missing(response_structure)) {
parameters <- list(address = email,
appName = app_name,
subject = subject,
content = content,
appUrl = app_url,
piaUrl = app[['url']],
encrypt = 'false')
config <- list(app = app[['app_key']],
time = time,
task = 'email',
parameters = parameters,
'_oydRepoName' = 'Scheduler')
} else {
parameters <- list(address = email,
appName = app_name,
subject = subject,
content = content,
appUrl = app_url,
piaUrl = app[['url']],
response_structure = response_structure,
repo_url = app[['url']],
repo_key = app[['app_key']],
repo_secret = app[['app_secret']],
encrypt = 'false')
config <- list(app = app[['app_key']],
time = time,
task = 'email',
email_response = TRUE,
parameters = parameters,
'_oydRepoName' = 'Scheduler')
}
if(missing(id)) {
writeItem(app,
itemsUrl(app[['url']], schedulerKey),
config)
} else {
updateItem(app,
itemsUrl(app[['url']], schedulerKey),
config,
id)
}
}
getLocalEmailConfig <- reactive({
validEmailConfig <- FALSE
server <- input$mailer_address
port <- input$mailer_port
user <- input$mailer_user
pwd <- input$mailer_password
if((nchar(server) > 0) &
(nchar(port) > 0) &
(nchar(user) > 0) &
(nchar(pwd) > 0)) {
validEmailConfig <- TRUE
}
c('valid' = validEmailConfig,
'server' = server,
'port' = port,
'user' = user,
'pwd' = pwd)
})
getPiaEmailConfig <- function(app){
url <- itemsUrl(app[['url']],
schedulerEmailConfigKey)
retVal <- readItems(app, url)
if(length(retVal) == 0 |
nrow(retVal) == 0) {
vector()
} else {
retVal
}
}
getPiaSchedulerEmail <- function(app) {
url <- itemsUrl(app[['url']], schedulerKey)
retVal <- readItems(app, url)
if(nrow(retVal) == 0) {
vector()
} else {
retVal <- retVal[retVal$app == app[['app_key']] &
retVal$task == 'email', ]
if(nrow(retVal) > 0) {
c(id=retVal$id,
email=retVal$parameters.address)
} else {
vector()
}
}
}