[web] Extract a function that creates web messages
Summary:
This logic was repeated, and I need to use it in the next diff.
Depends on D13137
Test Plan: Tests.
Reviewers: kamil, inka
Reviewed By: kamil
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D13138