Fix sytest again

This commit is contained in:
Till Faelligen 2022-11-03 13:51:14 +01:00
parent abdb1cfbfe
commit d1781c634e
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
2 changed files with 10 additions and 17 deletions

View file

@ -103,18 +103,10 @@ func GetPresence(
JSON: jsonerror.InternalServerError(), JSON: jsonerror.InternalServerError(),
} }
} }
log.Debugf("XXX: 1")
statusMsg := presence.Header.Get("status_msg") statusMsg := presence.Header.Get("status_msg")
e := presence.Header.Get("error") e := presence.Header.Get("error")
if e != "" { if e != "" {
log.Errorf("received error msg from nats: %s", e)
if code := presence.Header.Get("error_code"); code == "404" {
return util.JSONResponse{
Code: http.StatusNotFound,
JSON: jsonerror.NotFound("No status for user found."),
}
}
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusOK, Code: http.StatusOK,
JSON: types.PresenceClientResponse{ JSON: types.PresenceClientResponse{
@ -122,14 +114,17 @@ func GetPresence(
}, },
} }
} }
log.Debugf("XXX: 2")
lastActive, err := strconv.Atoi(presence.Header.Get("last_active_ts")) lastActive, err := strconv.Atoi(presence.Header.Get("last_active_ts"))
if err != nil { if err != nil {
log.WithError(err).Errorf("WTF?!")
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusInternalServerError, Code: http.StatusInternalServerError,
JSON: jsonerror.InternalServerError(), JSON: jsonerror.InternalServerError(),
} }
} }
log.Debugf("XXX: 3")
p := types.PresenceInternal{LastActiveTS: gomatrixserverlib.Timestamp(lastActive)} p := types.PresenceInternal{LastActiveTS: gomatrixserverlib.Timestamp(lastActive)}
currentlyActive := p.CurrentlyActive() currentlyActive := p.CurrentlyActive()
return util.JSONResponse{ return util.JSONResponse{

View file

@ -89,15 +89,13 @@ func (s *PresenceConsumer) Start() error {
} }
return return
} }
if len(presences) == 0 {
m.Header.Set("error", "presence does not exist") presence := &types.PresenceInternal{
m.Header.Set("error_code", "404") UserID: userID,
if err = msg.RespondMsg(msg); err != nil {
logrus.WithError(err).Error("Unable to respond to messages")
} }
return if len(presences) > 0 {
presence = presences[0]
} }
presence := presences[0]
deviceRes := api.QueryDevicesResponse{} deviceRes := api.QueryDevicesResponse{}
if err = s.deviceAPI.QueryDevices(s.ctx, &api.QueryDevicesRequest{UserID: userID}, &deviceRes); err != nil { if err = s.deviceAPI.QueryDevices(s.ctx, &api.QueryDevicesRequest{UserID: userID}, &deviceRes); err != nil {