This narration tells us that the companions were in mosque for Friday prayer, The Prophet(pbuh) was delivering sermon for Fridays prayer, when outside caravan came, everybody left the Prophet and rushed to caravan, only 12 people remained in mosque, the verse of Surah Jumma revealed about it.