RedactRawSyncData runs HashRedact on the given sync data.
(syncData []byte, redactSalt string)
| 196 | |
| 197 | // RedactRawSyncData runs HashRedact on the given sync data. |
| 198 | func RedactRawSyncData(syncData []byte, redactSalt string) ([]byte, error) { |
| 199 | if redactSalt == "" { |
| 200 | return nil, fmt.Errorf("redact salt must be set") |
| 201 | } |
| 202 | |
| 203 | var sd SyncData |
| 204 | if err := json.Unmarshal(syncData, &sd); err != nil { |
| 205 | return nil, fmt.Errorf("couldn't unmarshal sync data: %w", err) |
| 206 | } |
| 207 | |
| 208 | if err := sd.HashRedact(redactSalt); err != nil { |
| 209 | return nil, fmt.Errorf("couldn't redact sync data: %w", err) |
| 210 | } |
| 211 | |
| 212 | return json.Marshal(sd) |
| 213 | } |
| 214 | |
| 215 | // HashRedact does in-place redaction of UserData inside SyncData, by hashing channel names, user access, role access, and attachment names. |
| 216 | func (sd *SyncData) HashRedact(salt string) error { |
no test coverage detected