many thanks to tamas.io https://github.com/tamaspiros/advanced-chat which this was originally based