Добавлена поддержка отображения подписанных текстур

This commit is contained in:
ErickSkrauch 2017-04-01 12:18:57 +03:00
parent d3b4bee3b0
commit e652691b29
6 changed files with 82 additions and 18 deletions

View File

@ -0,0 +1,14 @@
package data
type SignedTexturesResponse struct {
Id string `json:"id"`
Name string `json:"name"`
IsEly bool `json:"ely,omitempty"`
Props []Property `json:"properties"`
}
type Property struct {
Name string `json:"name"`
Signature string `json:"signature"`
Value string `json:"value"`
}

View File

@ -12,14 +12,17 @@ import (
)
type SkinItem struct {
UserId int `json:"userId"`
Username string `json:"username"`
SkinId int `json:"skinId"`
Url string `json:"url"`
Is1_8 bool `json:"is1_8"`
IsSlim bool `json:"isSlim"`
Hash string `json:"hash"`
oldUsername string
UserId int `json:"userId"`
Uuid string `json:"uuid"`
Username string `json:"username"`
SkinId int `json:"skinId"`
Url string `json:"url"`
Is1_8 bool `json:"is1_8"`
IsSlim bool `json:"isSlim"`
Hash string `json:"hash"`
MojangTextures string `json:"mojangTextures"`
MojangSignature string `json:"mojangSignature"`
oldUsername string
}
const accountIdToUsernameKey string = "hash:username-to-account-id"

View File

@ -0,0 +1,40 @@
package routes
import (
"strings"
"net/http"
"encoding/json"
"github.com/gorilla/mux"
"elyby/minecraft-skinsystem/lib/data"
"elyby/minecraft-skinsystem/lib/tools"
"elyby/minecraft-skinsystem/lib/services"
)
func SignedTextures(w http.ResponseWriter, r *http.Request) {
services.Logger.IncCounter("signed_textures.request", 1)
username := tools.ParseUsername(mux.Vars(r)["username"])
rec, err := data.FindSkinByUsername(username)
if (err != nil || rec.SkinId == 0) {
w.WriteHeader(http.StatusNoContent)
return
}
responseData:= data.SignedTexturesResponse{
Id: strings.Replace(rec.Uuid, "-", "", -1),
Name: rec.Username,
Props: []data.Property{
{
Name: "textures",
Signature: rec.MojangSignature,
Value: rec.MojangTextures,
},
},
}
response,_ := json.Marshal(responseData)
w.Header().Set("Content-Type", "application/json")
w.Write(response)
}

View File

@ -42,11 +42,14 @@ func handleSkinChanged(model skinChanged) (bool) {
return true
}
record.Uuid = model.Uuid
record.SkinId = model.SkinId
record.Hash = model.Hash
record.Is1_8 = model.Is1_8
record.Hash = model.Hash
record.Is1_8 = model.Is1_8
record.IsSlim = model.IsSlim
record.Url = model.Url
record.Url = model.Url
record.MojangTextures = model.MojangTextures
record.MojangSignature = model.MojangSignature
record.Save()

View File

@ -7,11 +7,14 @@ type usernameChanged struct {
}
type skinChanged struct {
AccountId int `json:"userId"`
SkinId int `json:"skinId"`
OldSkinId int `json:"oldSkinId"`
Hash string `json:"hash"`
Is1_8 bool `json:"is1_8"`
IsSlim bool `json:"isSlim"`
Url string `json:"url"`
AccountId int `json:"userId"`
Uuid string `json:"uuid"`
SkinId int `json:"skinId"`
OldSkinId int `json:"oldSkinId"`
Hash string `json:"hash"`
Is1_8 bool `json:"is1_8"`
IsSlim bool `json:"isSlim"`
Url string `json:"url"`
MojangTextures string `json:"mojangTextures"`
MojangSignature string `json:"mojangSignature"`
}

View File

@ -85,6 +85,7 @@ func main() {
router.HandleFunc("/skins/{username}", routes.Skin).Methods("GET").Name("skins")
router.HandleFunc("/cloaks/{username}", routes.Cape).Methods("GET").Name("cloaks")
router.HandleFunc("/textures/{username}", routes.Textures).Methods("GET").Name("textures")
router.HandleFunc("/textures/signed/{username}", routes.SignedTextures).Methods("GET").Name("signedTextures")
router.HandleFunc("/skins/{username}/face", routes.Face).Methods("GET").Name("faces")
router.HandleFunc("/skins/{username}/face.png", routes.Face).Methods("GET").Name("faces")
// Legacy