databag/net/server/internal/api_getProfileMessage.go

37 lines
861 B
Go
Raw Normal View History

2022-01-20 08:05:12 +00:00
package databag
import (
"net/http"
)
func GetProfileMessage(w http.ResponseWriter, r *http.Request) {
2022-01-20 23:19:26 +00:00
account, code, res := BearerAppToken(r, true);
2022-01-20 08:05:12 +00:00
if res != nil {
2022-01-20 23:19:26 +00:00
ErrResponse(w, code, res)
2022-01-20 08:05:12 +00:00
return
}
detail := account.AccountDetail
// generate identity DataMessage
identity := Identity{
Revision: account.ProfileRevision,
Handle: account.Username,
Name: detail.Name,
Description: detail.Description,
Location: detail.Location,
Image: detail.Image,
Version: APP_VERSION,
Node: "https://" + getStrConfigValue(CONFIG_DOMAIN, "") + "/",
}
msg, res := WriteDataMessage(detail.PrivateKey, detail.PublicKey, detail.KeyType,
APP_SIGNPKCS1V15, account.Guid, APP_MSGIDENTITY, &identity)
if res != nil {
ErrResponse(w, http.StatusInternalServerError, res)
return
}
WriteResponse(w, msg)
}