alert.go 657 B

123456789101112131415161718192021222324252627282930313233
  1. package server
  2. import (
  3. "context"
  4. "github.com/mkaminski/goaim/oscar"
  5. "log/slog"
  6. )
  7. func NewAlertRouter(logger *slog.Logger) AlertRouter {
  8. return AlertRouter{
  9. RouteLogger: RouteLogger{
  10. Logger: logger,
  11. },
  12. }
  13. }
  14. type AlertRouter struct {
  15. RouteLogger
  16. }
  17. func (rt *AlertRouter) RouteAlert(ctx context.Context, SNACFrame oscar.SnacFrame) error {
  18. switch SNACFrame.SubGroup {
  19. case oscar.AlertNotifyCapabilities:
  20. fallthrough
  21. case oscar.AlertNotifyDisplayCapabilities:
  22. // just read the request to placate the client. no need to send a
  23. // response.
  24. rt.logRequest(ctx, SNACFrame, nil)
  25. return nil
  26. default:
  27. return ErrUnsupportedSubGroup
  28. }
  29. }