-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.R
142 lines (109 loc) · 3.89 KB
/
server.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function(input, output, session) {
renderSurvey()
observeEvent(input$submit, {
posit_board <- board_connect()
previous <- posit_board |>
pin_read("renatadiaz/getinvolved_responses")
# Obtain and and append submitted results
response <- getSurveyData(custom_id = input$email,
include_dependencies = FALSE)
timestamp <- data.frame(
subject_id = input$email,
question_id = "timestamp",
question_type = "time",
response = as.character(Sys.time())
)
response <- bind_rows(response, timestamp)
response <- response |>
mutate(response_id = max(previous$response_id) + 1)
updated <- bind_rows(previous, response)
# Write back to pin
posit_board |>
pin_write(updated, "renatadiaz/getinvolved_responses")
email_ok <- check_email(input$email)
if(email_ok) {
# Show submission message
showModal(
modalDialog(
title = "Your answers have been recorded. Thank you!",
"Please reach out to Kim Novick ([email protected]) or Jessica Guo ([email protected]) with any questions. "
)
)
# Email
body_text0 <-
paste0("Hi ", input$name_first, " ", input$name_last, ",")
body_text1 <- paste("Thank you for expressing interest in PSInet!")
body_text2 <- ""
if (grepl("Slack", input$platform)) {
body_text2 <- paste0("Please use this invitation link to join our Slack channel: ", Sys.getenv("SLACK_LINK"), ".")
}
body_text2p5 <- ""
if (grepl("listserv", input$platform)) {
body_text2p5 <-
"This email address has been automatically added to the PSInet listserv."
}
body_text3 <- paste("We look forward to working with you!")
body_text4 <- "Sincerely,"
body_text5 <- "The PSInet team"
survey_message <- compose_email(
body = blocks(
body_text0,
block_spacer(),
body_text1,
block_spacer(),
body_text2,
block_spacer(),
body_text2p5,
block_spacer(),
body_text3,
block_spacer(),
body_text4,
block_spacer(),
body_text5
),
footer = "Please note that this email inbox is not monitored. If you have questions or concerns, please reach out to Jessica Guo ([email protected]) or Kim Novick ([email protected])."
)
smtp_send(
survey_message,
from = "[email protected]",
to = input$email,
subject = "Welcome to PSInet!",
credentials = creds_envvar(
user = "[email protected]",
pass_envvar = "SMTP_PASSWORD",
provider = NULL,
host = "smtp.gmail.com",
port = 465,
use_ssl = FALSE
)
)
if (grepl("listserv", input$platform)) {
# Send email to IU listserv inviting person
listserv_message <- compose_email(
body = paste("ADD psinet-l ", input$email)
)
smtp_send(listserv_message,
from = "[email protected]", #change this
to = "[email protected]",
subject = paste("ADD psinet-l ", input$email),
credentials = creds_envvar(
user = "[email protected]",
pass_envvar = "SMTP_PASSWORD",
provider = NULL,
host = "smtp.gmail.com",
port = 465,
use_ssl = FALSE
)
)
}
} else {
# Show submission message
showModal(
modalDialog(
title = "Please check the email provided; it does not appear to be valid!",
"Please reach out to Kim Novick ([email protected]) or Jessica Guo ([email protected]) with any questions. "
)
)
}
})
}