visibleFile method
The file fileId when principalId may read it: the uploader, or anyone who sees the
thread of the message it is attached to (12 3.7); else 404 not_found.
Implementation
FakeFile visibleFile(String principalId, String fileId) {
final f = files[fileId];
if (f == null) throw const FakeProblem(404, 'not_found');
if (f.uploadedBy == principalId) return f;
final message = messages[f.attachedTo];
if (message != null &&
message['deleted_at'] == null &&
seesThread(principalId, message['thread_id']! as String)) {
return f;
}
throw const FakeProblem(404, 'not_found');
}