fix: fix crash in API v1 when message.System is null

This commit is contained in:
spiral 2022-01-14 19:47:12 -05:00
parent f08524ee19
commit 6d1fd0e267
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31

View File

@ -26,6 +26,7 @@ public class MessageController: ControllerBase
var msg = await _db.Execute(c => _repo.GetMessage(c, mid)); var msg = await _db.Execute(c => _repo.GetMessage(c, mid));
if (msg == null) return NotFound("Message not found."); if (msg == null) return NotFound("Message not found.");
return msg.ToJson(User.ContextFor(msg.System), APIVersion.V1); var ctx = msg.System == null ? LookupContext.ByNonOwner : User.ContextFor(msg.System);
return msg.ToJson(ctx, APIVersion.V1);
} }
} }