mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
Merge pull request #604 from tactilenews/extend_update_profile_with_description
Add ability to update about text in UpdateProfileRequest
This commit is contained in:
@@ -146,6 +146,7 @@ type CreateGroupResponse struct {
|
|||||||
type UpdateProfileRequest struct {
|
type UpdateProfileRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Base64Avatar string `json:"base64_avatar"`
|
Base64Avatar string `json:"base64_avatar"`
|
||||||
|
About *string `json:"about"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrustIdentityRequest struct {
|
type TrustIdentityRequest struct {
|
||||||
@@ -1115,7 +1116,7 @@ func (a *Api) UpdateProfile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = a.signalClient.UpdateProfile(number, req.Name, req.Base64Avatar)
|
err = a.signalClient.UpdateProfile(number, req.Name, req.Base64Avatar, req.About)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(400, Error{Msg: err.Error()})
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1356,7 +1356,7 @@ func (s *SignalClient) GetAttachment(attachment string) ([]byte, error) {
|
|||||||
return attachmentBytes, nil
|
return attachmentBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SignalClient) UpdateProfile(number string, profileName string, base64Avatar string) error {
|
func (s *SignalClient) UpdateProfile(number string, profileName string, base64Avatar string, about *string) error {
|
||||||
var err error
|
var err error
|
||||||
var avatarTmpPath string
|
var avatarTmpPath string
|
||||||
if base64Avatar != "" {
|
if base64Avatar != "" {
|
||||||
@@ -1399,14 +1399,17 @@ func (s *SignalClient) UpdateProfile(number string, profileName string, base64Av
|
|||||||
Name string `json:"given-name"`
|
Name string `json:"given-name"`
|
||||||
Avatar string `json:"avatar,omitempty"`
|
Avatar string `json:"avatar,omitempty"`
|
||||||
RemoveAvatar bool `json:"remove-avatar"`
|
RemoveAvatar bool `json:"remove-avatar"`
|
||||||
|
About *string `json:"about,omitempty"`
|
||||||
}
|
}
|
||||||
request := Request{Name: profileName}
|
request := Request{Name: profileName}
|
||||||
|
request.About = about
|
||||||
if base64Avatar == "" {
|
if base64Avatar == "" {
|
||||||
request.RemoveAvatar = true
|
request.RemoveAvatar = true
|
||||||
} else {
|
} else {
|
||||||
request.Avatar = avatarTmpPath
|
request.Avatar = avatarTmpPath
|
||||||
request.RemoveAvatar = false
|
request.RemoveAvatar = false
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonRpc2Client, err := s.getJsonRpc2Client()
|
jsonRpc2Client, err := s.getJsonRpc2Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1420,6 +1423,10 @@ func (s *SignalClient) UpdateProfile(number string, profileName string, base64Av
|
|||||||
cmd = append(cmd, []string{"--avatar", avatarTmpPath}...)
|
cmd = append(cmd, []string{"--avatar", avatarTmpPath}...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if about != nil {
|
||||||
|
cmd = append(cmd, []string{"--about", *about}...)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = s.cliClient.Execute(true, cmd, "")
|
_, err = s.cliClient.Execute(true, cmd, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user