The Messenger of Allah ﷺ said, "When you see a man frequenting the masjid, bear witness that he has faith, for Allah Most High has said, 'The masjids of Allah are maintained only by those who believe in Allah and the Last Day' [Tawbah 9:18]."Ibn Abu Umar narrated to us, Abdullah bin Wahb narrated to us, from Amr bin Harith, from Darraj, from Abu Haytham, from Abu Saeed, from the Prophet ﷺ, something similar, except that he said, "one who keeps up his attendance at the masjid."
حدثنا أبو كريب حدثنا رشدين بن سعد عن عمرو بن الحارث عن دراج عن أبي الهيثم
قال رسول الله ﷺ إذا رأيتم الرجل يعتاد المسجد فاشهدوا له بالإيمان قال الله تعالى {إنما يعمر مساجد الله من آمن بالله واليوم الآخر} حدثنا ابن أبي عمر حدثنا عبد الله بن وهب عن عمرو بن الحارث عن دراج عن أبي الهيثم عن أبي سعيد عن النبي ﷺ نحوه إلا أنه قال يتعاهد المسجد
Sourcing, [Its chain is daif]. Ibn Majah also narrated it in the chapter Iqamat al-Salawat, section "The obligation of staying in mosques and awaiting prayer," no. 802, from Abu Kurayb, with this same wording. It has previously appeared as no. 2617.