Add a pointer to conditionally send about string to signal-cli

This commit is contained in:
Matthew Rider
2024-10-22 10:27:32 +02:00
parent f6c3f263e8
commit 57dcb2f281
2 changed files with 10 additions and 4 deletions

View File

@@ -146,7 +146,7 @@ type CreateGroupResponse struct {
type UpdateProfileRequest struct {
Name string `json:"name"`
Base64Avatar string `json:"base64_avatar"`
About string `json:"about"`
About *string `json:"about"`
}
type TrustIdentityRequest struct {

View File

@@ -1356,7 +1356,7 @@ func (s *SignalClient) GetAttachment(attachment string) ([]byte, error) {
return attachmentBytes, nil
}
func (s *SignalClient) UpdateProfile(number string, profileName string, base64Avatar string, about string) error {
func (s *SignalClient) UpdateProfile(number string, profileName string, base64Avatar string, about *string) error {
var err error
var avatarTmpPath string
if base64Avatar != "" {
@@ -1399,28 +1399,34 @@ func (s *SignalClient) UpdateProfile(number string, profileName string, base64Av
Name string `json:"given-name"`
Avatar string `json:"avatar,omitempty"`
RemoveAvatar bool `json:"remove-avatar"`
About string `json:"about"`
About *string `json:"about,omitempty"`
}
request := Request{Name: profileName}
request.About = about
if base64Avatar == "" {
request.RemoveAvatar = true
} else {
request.Avatar = avatarTmpPath
request.RemoveAvatar = false
}
jsonRpc2Client, err := s.getJsonRpc2Client()
if err != nil {
return err
}
_, err = jsonRpc2Client.getRaw("updateProfile", &number, request)
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "updateProfile", "--given-name", profileName, "--about", about}
cmd := []string{"--config", s.signalCliConfig, "-a", number, "updateProfile", "--given-name", profileName}
if base64Avatar == "" {
cmd = append(cmd, "--remove-avatar")
} else {
cmd = append(cmd, []string{"--avatar", avatarTmpPath}...)
}
if about != nil {
cmd = append(cmd, []string{"--about", *about}...)
}
_, err = s.cliClient.Execute(true, cmd, "")
}