im
Clone
https://git.tahinli.com/Tahinli/im.git
0 watching0 forksRustAGPL-3.0542.8 KiBb9f0726Tahinli27 days ago34 commits
| 1 | //! `GET /api/v1/people/{sub}/photo` (`docs/contracts.md` section 3.2): a person's profile photo, as bytes. |
| 2 | //! |
| 3 | //! The `sub` must be a ULID, else `404`. A person with no photo, an unknown or deleted person, and a photo |
| 4 | //! whose stored type is not on the allowlist are all `404`, so the answer does not say which it was. There |
| 5 | //! is no initials picture for a machine. The bytes go with `nosniff` and a `"p<picture_version>"` ETag. With |
| 6 | //! `?v=` equal to the current version the answer may be cached for a year (the URL names the version); |
| 7 | //! otherwise it may be kept but must be checked again. `If-None-Match` gets a `304`. |
| 8 | |
| 9 | use ; |
| 10 | use read_photo; |
| 11 | use Result; |
| 12 | use ; |
| 13 | use ; |
| 14 | use Response; |
| 15 | use ; |
| 16 | |
| 17 | use ; |
| 18 | use ; |
| 19 | use crate; |
| 20 | use crateAppState; |
| 21 | |
| 22 | /// The image types a photo may be served as. Anything else stored is not served. |
| 23 | pub const ALLOWED_TYPES: = ; |
| 24 | |
| 25 | /// Caching when `?v=` names the current version: the URL is unique to this picture. |
| 26 | const IMMUTABLE_CACHE: &str = "private, max-age=31536000, immutable"; |
| 27 | |
| 28 | /// Caching otherwise: keep it, but ask again before use. |
| 29 | const REVALIDATE_CACHE: &str = "private, no-cache"; |
| 30 | |
| 31 | /// `GET /api/v1/people/{sub}/photo`. |
| 32 | |
| 33 | async |
| 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 | /// The `{sub}` of the matched route, or `None`. |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | /// The `v` query parameter as a version, when it is exactly one integer. |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | /// True when `If-None-Match` names `etag`. |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | /// The stored type, when it is on the allowlist. |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | /// A user id is a ULID: 26 characters of Crockford base32, the first at most `7`. Anything else (a path |
| 130 | /// fragment, an encoded slash, a dot segment) is refused before it reaches the disk. |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | /// One photo answer with its headers. |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 |