datawookie / emayili

Compare 479d818 ... +16 ... 60b05d9

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -1,19 +1,17 @@
Loading
1 1
# Headers for the MIME protocol.
2 2
3 3
content_type <- function(type, protocol, charset, boundary, format = NA, name = NA) {
4 -
  new_header(
4 +
  header(
5 5
    "Content-Type",
6 -
    paste(
7 -
      c(
8 -
        type,
9 -
        if (!is.na(protocol)) glue('protocol="{protocol}"') else NULL,
10 -
        if (!is.na(charset)) glue('charset={charset}') else NULL,
11 -
        if (!is.na(boundary)) glue('boundary="{boundary}"') else NULL,
12 -
        if (!is.na(format)) glue('format={format}') else NULL,
13 -
        if (!is.na(name)) glue('name="{name}"') else NULL
14 -
      ),
15 -
      collapse = "; "
16 -
    )
6 +
    c(
7 +
      type,
8 +
      if (!is.na(protocol)) glue('protocol="{protocol}"') else NULL,
9 +
      if (!is.na(charset)) glue('charset={charset}') else NULL,
10 +
      if (!is.na(boundary)) glue('boundary="{boundary}"') else NULL,
11 +
      if (!is.na(format)) glue('format={format}') else NULL,
12 +
      if (!is.na(name)) glue('name="{name}"') else NULL
13 +
    ),
14 +
    sep = "; "
17 15
  )
18 16
}
19 17
@@ -24,42 +22,42 @@
Loading
24 22
    if (!is.na(filename)) {
25 23
      disposition <- paste(disposition, glue('filename="{filename}"'), sep = "; ")
26 24
    }
27 -
    new_header("Content-Disposition", disposition)
25 +
    header("Content-Disposition", disposition)
28 26
  }
29 27
}
30 28
31 29
content_transfer_encoding <- function(encoding = NA) {
32 30
  if (is.na(encoding)) {
33 31
    NULL
34 32
  } else {
35 -
    new_header("Content-Transfer-Encoding", encoding)
33 +
    header("Content-Transfer-Encoding", encoding)
36 34
  }
37 35
}
38 36
39 37
content_description <- function(description = NA) {
40 38
  if (is.na(description)) {
41 39
    NULL
42 40
  } else {
43 -
    new_header("Content-Description", description)
41 +
    header("Content-Description", description)
44 42
  }
45 43
}
46 44
47 45
x_attachment_id <- function(cid = NULL) {
48 46
  if (is.null(cid)) {
49 47
    NULL
50 48
  } else {
51 -
    new_header("X-Attachment-Id", cid)
49 +
    header("X-Attachment-Id", cid)
52 50
  }
53 51
}
54 52
55 53
content_id <- function(cid = NULL) {
56 54
  if (is.null(cid)) {
57 55
    NULL
58 56
  } else {
59 -
    new_header("Content-ID", paste0("<", cid, ">"))
57 +
    header("Content-ID", paste0("<", cid, ">"))
60 58
  }
61 59
}
62 60
63 61
content_md5 <- function(content) {
64 -
  new_header("Content-MD5", md5(content))
62 +
  header("Content-MD5", md5(content))
65 63
}

@@ -153,6 +153,34 @@
Loading
153 153
  )
154 154
}
155 155
156 +
#' Create \code{multipart/signed} MIME object
157 +
#'
158 +
#' @noRd
159 +
#'
160 +
#' @inheritParams MIME
161 +
#' @param micalg Message Integrity Check ALGorithm. Valid options are:
162 +
#'   \code{"pgp-sha256"}, \code{"pgp-md5"}, \code{"pgp-sha1"},
163 +
#'   \code{"pgp-ripemd160"}, \code{"pgp-md2"}, \code{"pgp-tiger192"}, and
164 +
#'  \code{"pgp-haval-5-160"}.
165 +
multipart_signed <- function(
166 +
  micalg = "pgp-sha256",
167 +
  ...
168 +
) {
169 +
  if (!(micalg %in% LEVELS_MICALG)) stop('Invalid micalg: "{micalg}".')
170 +
  structure(
171 +
    c(
172 +
      MIME(
173 +
        "This is an OpenPGP/MIME signed message (RFC 4880 and 3156).",
174 +
        protocol = "application/pgp-signature",
175 +
        type = c("multipart/signed", 'micalg="{micalg}"'),
176 +
        ...
177 +
      ),
178 +
      list()
179 +
    ),
180 +
    class = c("multipart_signed", "MIME")
181 +
  )
182 +
}
183 +
156 184
application_pgp_encrypted <- function(
157 185
  content = "Version: 1",
158 186
  ...
@@ -172,6 +200,51 @@
Loading
172 200
  )
173 201
}
174 202
203 +
application_pgp_signature <- function(
204 +
  content,
205 +
  ...
206 +
) {
207 +
  structure(
208 +
    c(
209 +
      MIME(
210 +
        content,
211 +
        type = "application/pgp-signature",
212 +
        description = "OpenPGP digital signature",
213 +
        name = "signature.asc",
214 +
        filename = "signature.asc",
215 +
        disposition = "attachment",
216 +
        boundary = NA,
217 +
        ...
218 +
      ),
219 +
      list()
220 +
    ),
221 +
    class = c("application_pgp_signature", "MIME")
222 +
  )
223 +
}
224 +
225 +
application_pgp_keys <- function(
226 +
  content,
227 +
  ...
228 +
) {
229 +
  structure(
230 +
    c(
231 +
      MIME(
232 +
        content,
233 +
        type = "application/pgp-keys",
234 +
        description = "OpenPGP public key",
235 +
        name = "keys.asc",
236 +
        filename = "keys.asc",
237 +
        disposition = "attachment",
238 +
        encoding = "quoted-printable",
239 +
        boundary = NA,
240 +
        ...
241 +
      ),
242 +
      list()
243 +
    ),
244 +
    class = c("application_pgp_keys", "MIME")
245 +
  )
246 +
}
247 +
175 248
application_octet_stream <- function(
176 249
  content,
177 250
  disposition = "inline",

@@ -1,4 +1,4 @@
Loading
1 -
new_header <- function(
1 +
header <- function(
2 2
  name,
3 3
  values,
4 4
  sep = NULL
@@ -18,19 +18,34 @@
Loading
18 18
#' Accepts a header object and formats it as a header field.
19 19
#'
20 20
#' @param x A header object.
21 +
#' @param width The width of the head name field.
21 22
#' @param ... Further arguments passed to or from other methods.
22 23
#' @export
23 24
#'
24 25
#' @return A formatted header field.
25 -
as.character.header <- function(x, ...) {
26 -
  sprintf(
27 -
    "%-28s %s",
26 +
as.character.header <- function(x, width = 28, ...) {
27 +
  FORMAT <- glue("%-{width}s %s")
28 +
  INDENT <- strrep(" ", width + 1)
29 +
30 +
  header <- sprintf(
31 +
    FORMAT,
28 32
    paste0(x$name, ":"),
29 33
    paste(
30 34
      sapply(x$values, as.character),
31 35
      collapse = x$sep
32 36
    )
33 37
  )
38 +
39 +
  # Split header parameters across lines.
40 +
  if (!is.null(x$sep)) {
41 +
    header <- header %>%
42 +
      str_replace_all(
43 +
        paste0("(", str_trim(x$sep, side = "right"), ")"),
44 +
        paste0("\\1", CRLF, INDENT)
45 +
      )
46 +
  }
47 +
48 +
  header
34 49
}
35 50
36 51
print.header <- function(x, ... ) {
@@ -46,7 +61,7 @@
Loading
46 61
  header <- msg$headers[[name]]
47 62
  # Header has not previously been set.
48 63
  if (is.null(header)) {
49 -
    header <- new_header(name, c(), sep)
64 +
    header <- header(name, c(), sep)
50 65
  } else {
51 66
    if (append) {
52 67
      values <- c(header$values, values)

@@ -166,8 +166,8 @@
Loading
166 166
167 167
# If {memoise} is installed then memoise manifest().
168 168
#
169 -
if (require(memoise, quietly = TRUE)) {
170 -
  manifest <- memoise(manifest)
169 +
if (requireNamespace("memoise", quietly = TRUE)) {
170 +
  manifest <- memoise::memoise(manifest)
171 171
}
172 172
173 173
#' Render Markdown into email

@@ -220,3 +220,8 @@
Loading
220 220
221 221
  sprintf("%s%s:%d/%s", protocol, host, port, helo)
222 222
}
223 +
224 +
stop <- function(..., call. = FALSE, domain = NULL) {
225 +
  txt <- glue::glue(...)
226 +
  base::stop(txt, call. = call., domain = domain)
227 +
}

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 2 files with coverage changes found.

Changes in R/encrypt.R
-2
+2
Loading file...
Changes in R/mime.R
-28
+28
Loading file...
Files Coverage
R +6.83% 97.56%
Project Totals (20 files) 97.56%
Loading