Update database and sync API to support large messages
Subtask of #1237.
issue