commit b036c518b38ff3fd8b6ba80b2949d00813fea5fb
parent c962ae07215c515a256ba7f118878098cf41e46b
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 5 Jun 2023 20:27:39 -0700
simplify code
Diffstat:
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go
@@ -438,27 +438,29 @@ func (c *Command) getZeroUser() database.User {
return *c.zeroUser
}
-// Have the "zero" bot account send a message to the authUser
-func (c *Command) zeroMsg(msg string) {
- zeroUser := c.getZeroUser()
- c.rawMsg(zeroUser, c.authUser, msg, msg)
-}
-
// Have the "zero" bot account send a processed message to the user
func (c *Command) zeroProcMsg(rawMsg string) {
c.zeroProcMsgRoom(rawMsg, c.roomKey, c.room.ID)
}
+func (c *Command) zeroPublicProcMsgRoom(rawMsg, roomKey string, roomID database.RoomID) {
+ c.zeroProcMsgRoomToUser(rawMsg, roomKey, roomID, nil)
+}
+
func (c *Command) zeroProcMsgRoom(rawMsg, roomKey string, roomID database.RoomID) {
+ c.zeroProcMsgRoomToUser(rawMsg, roomKey, roomID, c.authUser)
+}
+
+func (c *Command) zeroProcMsgRoomToUser(rawMsg, roomKey string, roomID database.RoomID, toUser *database.User) {
zeroUser := c.getZeroUser()
procMsg, _, _ := ProcessRawMessage(c.db, rawMsg, roomKey, c.authUser.ID, roomID, nil, true)
- rawMsgRoom(c.db, zeroUser, c.authUser, rawMsg, procMsg, roomKey, roomID)
+ rawMsgRoom(c.db, zeroUser, toUser, rawMsg, procMsg, roomKey, roomID)
}
-func (c *Command) zeroPublicProcMsgRoom(rawMsg, roomKey string, roomID database.RoomID) {
+// Have the "zero" bot account send a message to the authUser
+func (c *Command) zeroMsg(msg string) {
zeroUser := c.getZeroUser()
- procMsg, _, _ := ProcessRawMessage(c.db, rawMsg, roomKey, c.authUser.ID, roomID, nil, true)
- rawMsgRoom(c.db, zeroUser, nil, rawMsg, procMsg, roomKey, roomID)
+ c.rawMsg(zeroUser, c.authUser, msg, msg)
}
func (c *Command) zeroPublicMsg(raw, msg string) {