alert.go 652 B

12345678910111213141516171819202122232425262728293031323334
  1. package server
  2. import (
  3. "context"
  4. "log/slog"
  5. "github.com/mkaminski/goaim/oscar"
  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, inFrame oscar.SNACFrame) error {
  18. switch inFrame.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, inFrame, nil)
  25. return nil
  26. default:
  27. return ErrUnsupportedSubGroup
  28. }
  29. }