Implemented API for full CRD of IdentityImages
This commit is contained in:
parent
2960fc49d4
commit
fcbd9285f6
|
@ -1271,8 +1271,8 @@ func (b *GethStatusBackend) SignHash(hexEncodedHash string) (string, error) {
|
||||||
return hexEncodedSignature, nil
|
return hexEncodedSignature, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProfileImages returns an array of base64 encoded images related to the user's profile
|
// GetIdentityImages returns an array of json marshalled IdentityImages assigned to the user's identity
|
||||||
func (b *GethStatusBackend) GetProfileImages() (string, error) {
|
func (b *GethStatusBackend) GetIdentityImages() (string, error) {
|
||||||
idb := images.NewDatabase(b.appDB)
|
idb := images.NewDatabase(b.appDB)
|
||||||
iis, err := idb.GetIdentityImages()
|
iis, err := idb.GetIdentityImages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1284,11 +1284,24 @@ func (b *GethStatusBackend) GetProfileImages() (string, error) {
|
||||||
return string(js), err
|
return string(js), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveProfileImage takes the filepath of an image, crops it as per the rect coords and finally resizes the image.
|
// GetIdentityImage returns a json object representing the image with the given name
|
||||||
|
func (b *GethStatusBackend) GetIdentityImage(name string) (string, error) {
|
||||||
|
idb := images.NewDatabase(b.appDB)
|
||||||
|
ii, err := idb.GetIdentityImage(name)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
js, err := json.Marshal(ii)
|
||||||
|
|
||||||
|
return string(js), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// StoreIdentityImage takes the filepath of an image, crops it as per the rect coords and finally resizes the image.
|
||||||
// The resulting image(s) will be stored in the DB along with other user account information.
|
// The resulting image(s) will be stored in the DB along with other user account information.
|
||||||
// aX and aY represent the pixel coordinates of the upper left corner of the image's cropping area
|
// aX and aY represent the pixel coordinates of the upper left corner of the image's cropping area
|
||||||
// bX and bY represent the pixel coordinates of the lower right corner of the image's cropping area
|
// bX and bY represent the pixel coordinates of the lower right corner of the image's cropping area
|
||||||
func (b *GethStatusBackend) SaveProfileImage(filepath string, aX, aY, bX, bY int) (string, error) {
|
func (b *GethStatusBackend) StoreIdentityImage(filepath string, aX, aY, bX, bY int) (string, error) {
|
||||||
iis, err := images.GenerateIdentityImages(filepath, aX, aY, bX, bY)
|
iis, err := images.GenerateIdentityImages(filepath, aX, aY, bX, bY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -1304,3 +1317,9 @@ func (b *GethStatusBackend) SaveProfileImage(filepath string, aX, aY, bX, bY int
|
||||||
|
|
||||||
return string(js), err
|
return string(js), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteIdentityImage deletes an IdentityImage from the db with the given name
|
||||||
|
func (b *GethStatusBackend) DeleteIdentityImage(name string) error {
|
||||||
|
idb := images.NewDatabase(b.appDB)
|
||||||
|
return idb.DeleteIdentityImage(name)
|
||||||
|
}
|
||||||
|
|
|
@ -629,9 +629,9 @@ func MultiformatDeserializePublicKey(key, outBase string) string {
|
||||||
return pk
|
return pk
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProfileImages returns an array of base64 encoded images related to the user's profile
|
// GetProfileImages returns an array of json marshalled IdentityImages assigned to the user's identity
|
||||||
func GetProfileImages() string {
|
func GetProfileImages() string {
|
||||||
pis, err := statusBackend.GetProfileImages()
|
pis, err := statusBackend.GetIdentityImages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return makeJSONResponse(err)
|
return makeJSONResponse(err)
|
||||||
}
|
}
|
||||||
|
@ -639,15 +639,35 @@ func GetProfileImages() string {
|
||||||
return pis
|
return pis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetProfileImage returns a json object representing the image with the given name
|
||||||
|
func GetProfileImage(name string) string {
|
||||||
|
ii, err := statusBackend.GetIdentityImage(name)
|
||||||
|
if err != nil {
|
||||||
|
return makeJSONResponse(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ii
|
||||||
|
}
|
||||||
|
|
||||||
// SaveProfileImage takes the filepath of an image, crops it as per the rect coords and finally resizes the image.
|
// SaveProfileImage takes the filepath of an image, crops it as per the rect coords and finally resizes the image.
|
||||||
// The resulting image(s) will be stored in the DB along with other user account information.
|
// The resulting image(s) will be stored in the DB along with other user account information.
|
||||||
// aX and aY represent the pixel coordinates of the upper left corner of the image's cropping area
|
// aX and aY represent the pixel coordinates of the upper left corner of the image's cropping area
|
||||||
// bX and bY represent the pixel coordinates of the lower right corner of the image's cropping area
|
// bX and bY represent the pixel coordinates of the lower right corner of the image's cropping area
|
||||||
func SaveProfileImage(filepath string, aX, aY, bX, bY int) string {
|
func SaveProfileImage(filepath string, aX, aY, bX, bY int) string {
|
||||||
imgs, err := statusBackend.SaveProfileImage(filepath, aX, aY, bX, bY)
|
imgs, err := statusBackend.StoreIdentityImage(filepath, aX, aY, bX, bY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return makeJSONResponse(err)
|
return makeJSONResponse(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return imgs
|
return imgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteProfileImage deletes an IdentityImage from the db with the given name
|
||||||
|
func DeleteProfileImage(name string) string {
|
||||||
|
err := statusBackend.DeleteIdentityImage(name)
|
||||||
|
if err != nil {
|
||||||
|
return makeJSONResponse(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return "ok"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue