Skip to content

Commit bcbc979

Browse files
authored
[IMP] Adds a Status (200) field to Me and Presence response for consistency (#427)
1 parent 74e6649 commit bcbc979

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

internal/service/me/me.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func (s *Service) OnRequest(c service.Conn, payload []byte) (service.Response, b
4545
}
4646

4747
return &Response{
48-
ID: c.ID(),
49-
Links: links,
48+
Status: 200,
49+
ID: c.ID(),
50+
Links: links,
5051
}, true
5152
}

internal/service/me/requests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package me
1717
// Response represents a response for the 'me' request.
1818
type Response struct {
1919
Request uint16 `json:"req,omitempty"` // The corresponding request ID.
20+
Status int `json:"status"` // The status of the response
2021
ID string `json:"id"` // The private ID of the connection.
2122
Links map[string]string `json:"links,omitempty"` // The set of pre-defined channels.
2223
}

internal/service/presence/presence.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,17 @@ func (s *Service) OnRequest(c service.Conn, payload []byte) (service.Response, b
9090
// Gather local & cluster presence
9191
who = append(who, s.getAllPresence(ssid)...)
9292
return &Response{
93+
Status: 200,
9394
Time: now,
9495
Event: EventTypeStatus,
9596
Channel: msg.Channel,
9697
Who: who,
9798
}, true
9899
}
99100

100-
return nil, true
101+
return &Response{
102+
Status: 200,
103+
}, true
101104
}
102105

103106
// OnHTTP occurs when a new HTTP presence request is received.

internal/service/presence/requests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const (
4545
// Response represents a state notification.
4646
type Response struct {
4747
Request uint16 `json:"req,omitempty"` // The corresponding request ID.
48+
Status int `json:"status"` // The status of the response
4849
Time int64 `json:"time"` // The UNIX timestamp.
4950
Event EventType `json:"event"` // The event, must be "status", "subscribe" or "unsubscribe".
5051
Channel string `json:"channel"` // The target channel for the notification.

0 commit comments

Comments
 (0)