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
[APIV4] GET /users/{user_id}/status - user status endpoint for apiV4 #5824
Conversation
api4/status.go
Outdated
c.Err = err | ||
return | ||
} else { | ||
resp["status"] = statusMap[0].Status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to check if len(statusMap) == 0
first and return a 404 NotFound error if it is. Also can we use statusMap[0].ToJson()
as the response body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah! true!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
api4/status.go
Outdated
} else { | ||
if len(statusMap) == 0 { | ||
c.Err = model.NewLocAppError("UserStatus", "api.status.user_not_found.app_error", nil, "") | ||
c.Err.StatusCode = http.StatusNotFound |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor but can we do c.Err = model.NewAppError("UserStatus", "api.status.user_not_found.app_error", nil, "", http.StatusNotFound)
instead? Minor difference between NewAppError
and NewLocAppError
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -22,7 +22,7 @@ type Status struct { | |||
Status string `json:"status"` | |||
Manual bool `json:"manual"` | |||
LastActivityAt int64 `json:"last_activity_at"` | |||
ActiveChannel string `json:"active_channel" db:"-"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it'll remove the active_channel
field from the existing API. What are the consequences of this from a backwards compatibility point of view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert, since I revert the manual as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not returned in APIv3 at all, so backwards compatibility is no issue. We should not return ActiveChannel
to the client since it doesn't need it and because it would be leaking channel IDs
Please see my comment, we should switch back to
|
Summary
This PR implements the GET /users/{user_id}/status - user status endpoint for apiV4
Ticket Link
n/a
Checklist