聊天签名
This commit is contained in:
parent
f9bba48f52
commit
c50289ce64
@ -177,3 +177,25 @@ func (y *Yggdrasil) BatchProfile() httprouter.Handle {
|
||||
w.Write(lo.Must1(json.Marshal(ul)))
|
||||
}
|
||||
}
|
||||
|
||||
func (y *Yggdrasil) PlayerCertificates() httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
ctx := r.Context()
|
||||
token := y.getTokenbyAuthorization(ctx, w, r)
|
||||
if token == "" {
|
||||
return
|
||||
}
|
||||
c, err := y.yggdrasilService.PlayerCertificates(ctx, token)
|
||||
if err != nil {
|
||||
if errors.Is(err, sutils.ErrTokenInvalid) {
|
||||
y.logger.DebugContext(ctx, err.Error())
|
||||
handleYgError(ctx, w, yggdrasil.Error{ErrorMessage: "Invalid token.", Error: "ForbiddenOperationException"}, 403)
|
||||
return
|
||||
}
|
||||
y.logger.WarnContext(ctx, err.Error())
|
||||
handleYgError(ctx, w, yggdrasil.Error{ErrorMessage: err.Error()}, 500)
|
||||
return
|
||||
}
|
||||
w.Write(lo.Must(json.Marshal(c)))
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ func newYggdrasil(r *httprouter.Router, handelY yggdrasil.Yggdrasil) error {
|
||||
r.POST("/api/yggdrasil/sessionserver/session/minecraft/join", warpHJSON(handelY.SessionJoin()))
|
||||
r.GET("/api/yggdrasil/sessionserver/session/minecraft/hasJoined", warpHJSON(handelY.SessionJoin()))
|
||||
|
||||
r.POST("/api/yggdrasil/minecraftservices/player/certificates", warpHJSON(handelY.PlayerCertificates()))
|
||||
|
||||
r.GET("/api/yggdrasil", warpHJSON(handelY.YggdrasilRoot()))
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user