| 86 | |
| 87 | /// Register all the callbacks our app will use to respond to database events. |
| 88 | void RegisterCallbacks(DbConnection conn) |
| 89 | { |
| 90 | conn.Db.User.OnInsert += User_OnInsert; |
| 91 | conn.Db.User.OnUpdate += User_OnUpdate; |
| 92 | |
| 93 | conn.Db.Message.OnInsert += Message_OnInsert; |
| 94 | |
| 95 | conn.Reducers.OnSetName += Reducer_OnSetNameEvent; |
| 96 | conn.Reducers.OnSendMessage += Reducer_OnSendMessageEvent; |
| 97 | } |
| 98 | |
| 99 | /// If the user has no set name, use the first 8 characters from their identity. |
| 100 | string UserNameOrIdentity(User user) => user.Name ?? user.Identity.ToString()[..8]; |