feat: realtime status, mentions, push notifications
This commit is contained in:
@@ -16,6 +16,14 @@ import (
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
db *sql.DB
|
||||
hub *gateway.Hub
|
||||
mentions *MentionHandler
|
||||
pushHandler *push.Handler
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
type Handler_old struct {
|
||||
db *sql.DB
|
||||
hub *gateway.Hub
|
||||
mentions *MentionHandler
|
||||
@@ -137,6 +145,16 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
// Dispatch push notifications for @mentions
|
||||
go h.mentions.ParseAndNotify(r.Context(), channelID, userID, req.Content)
|
||||
|
||||
// Dispatch push notifications to channel members
|
||||
go func() {
|
||||
var channelName string
|
||||
_ = h.db.QueryRowContext(context.Background(), `SELECT name FROM channels WHERE id = $1`, channelID).Scan(&channelName)
|
||||
if channelName == "" {
|
||||
channelName = channelID
|
||||
}
|
||||
h.pushHandler.SendChannelNotification(context.Background(), channelID, userID, channelName, req.Content)
|
||||
}()
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
json.NewEncoder(w).Encode(msg)
|
||||
|
||||
Reference in New Issue
Block a user