Top-quark effects in diphoton production through gluon fusion at next-to-leading order in QCD