Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] Adds a Status (200) field to Me and Presence response for consistency #427

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/service/me/me.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func (s *Service) OnRequest(c service.Conn, payload []byte) (service.Response, b
}

return &Response{
ID: c.ID(),
Links: links,
Status: 200,
ID: c.ID(),
Links: links,
}, true
}
1 change: 1 addition & 0 deletions internal/service/me/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package me
// Response represents a response for the 'me' request.
type Response struct {
Request uint16 `json:"req,omitempty"` // The corresponding request ID.
Status int `json:"status"` // The status of the response
ID string `json:"id"` // The private ID of the connection.
Links map[string]string `json:"links,omitempty"` // The set of pre-defined channels.
}
Expand Down
5 changes: 4 additions & 1 deletion internal/service/presence/presence.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,17 @@ func (s *Service) OnRequest(c service.Conn, payload []byte) (service.Response, b
// Gather local & cluster presence
who = append(who, s.getAllPresence(ssid)...)
return &Response{
Status: 200,
Time: now,
Event: EventTypeStatus,
Channel: msg.Channel,
Who: who,
}, true
}

return nil, true
return &Response{
Status: 200,
}, true
}

// OnHTTP occurs when a new HTTP presence request is received.
Expand Down
1 change: 1 addition & 0 deletions internal/service/presence/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
// Response represents a state notification.
type Response struct {
Request uint16 `json:"req,omitempty"` // The corresponding request ID.
Status int `json:"status"` // The status of the response
Time int64 `json:"time"` // The UNIX timestamp.
Event EventType `json:"event"` // The event, must be "status", "subscribe" or "unsubscribe".
Channel string `json:"channel"` // The target channel for the notification.
Expand Down
Loading