diff --git a/src/client/client.go b/src/client/client.go index 25a56e4..651911c 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -188,6 +188,20 @@ type ListInstalledStickerPacksResponse struct { Author string `json:"author"` } +type ContactProfile struct { + GivenName string `json:"given_name"` + FamilyName string `json:"lastname"` + About string `json:"about"` + HasAvatar bool `json:"has_avatar"` + LastUpdatedTimestamp int64 `json:"last_updated_timestamp"` +} + +type Nickname struct { + Name string `json:"name"` + GivenName string `json:"given_name"` + FamilyName string `json:"family_name"` +} + type ListContactsResponse struct { Number string `json:"number"` Uuid string `json:"uuid"` @@ -197,6 +211,10 @@ type ListContactsResponse struct { Color string `json:"color"` Blocked bool `json:"blocked"` MessageExpiration string `json:"message_expiration"` + Note string `json:"note"` + Profile ContactProfile `json:"profile"` + GivenName string `json:"given_name"` + Nickname Nickname `json:"nickname"` } func cleanupTmpFiles(paths []string) { @@ -2193,6 +2211,14 @@ func (s *SignalClient) AddStickerPack(number string, packId string, packKey stri } func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, error) { + type SignalCliProfileResponse struct { + LastUpdateTimestamp int64 `json:"lastUpdateTimestamp"` + GivenName string `json:"givenName"` + FamilyName string `json:"familyName"` + About string `json:"about"` + HasAvatar bool `json:"hasAvatar"` + } + type ListContactsSignlCliResponse struct { Number string `json:"number"` Uuid string `json:"uuid"` @@ -2202,6 +2228,12 @@ func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, erro Color string `json:"color"` Blocked bool `json:"blocked"` MessageExpiration string `json:"messageExpiration"` + Note string `json:"note"` + GivenName string `json:"givenName"` + Profile SignalCliProfileResponse `json:"profile"` + Nickname string `json:"nickName"` + NickGivenName string `json:"nickGivenName"` + NickFamilyName string `json:"nickFamilyName"` } resp := []ListContactsResponse{} @@ -2229,11 +2261,12 @@ func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, erro var signalCliResp []ListContactsSignlCliResponse err = json.Unmarshal([]byte(rawData), &signalCliResp) if err != nil { + log.Error("Couldn't list contacts", err.Error()) return resp, errors.New("Couldn't process request - invalid signal-cli response") } for _, value := range signalCliResp { - resp = append(resp, ListContactsResponse{ + entry := ListContactsResponse{ Number: value.Number, Uuid: value.Uuid, Name: value.Name, @@ -2242,7 +2275,18 @@ func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, erro Color: value.Color, Blocked: value.Blocked, MessageExpiration: value.MessageExpiration, - }) + Note: value.Note, + GivenName: value.GivenName, + } + entry.Profile.About = value.Profile.About + entry.Profile.HasAvatar = value.Profile.HasAvatar + entry.Profile.LastUpdatedTimestamp = value.Profile.LastUpdateTimestamp + entry.Profile.GivenName = value.Profile.GivenName + entry.Profile.FamilyName = value.Profile.FamilyName + entry.Nickname.Name = value.Nickname + entry.Nickname.GivenName = value.NickGivenName + entry.Nickname.FamilyName = value.NickFamilyName + resp = append(resp, entry) } return resp, nil diff --git a/src/docs/docs.go b/src/docs/docs.go index 3297423..d8c12ce 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -2594,6 +2594,26 @@ const docTemplate = `{ } } }, + "client.ContactProfile": { + "type": "object", + "properties": { + "about": { + "type": "string" + }, + "given_name": { + "type": "string" + }, + "has_avatar": { + "type": "boolean" + }, + "last_updated_timestamp": { + "type": "integer" + }, + "lastname": { + "type": "string" + } + } + }, "client.GroupEntry": { "type": "object", "properties": { @@ -2670,15 +2690,27 @@ const docTemplate = `{ "color": { "type": "string" }, + "given_name": { + "type": "string" + }, "message_expiration": { "type": "string" }, "name": { "type": "string" }, + "nickname": { + "$ref": "#/definitions/client.Nickname" + }, + "note": { + "type": "string" + }, "number": { "type": "string" }, + "profile": { + "$ref": "#/definitions/client.ContactProfile" + }, "profile_name": { "type": "string" }, @@ -2710,6 +2742,20 @@ const docTemplate = `{ } } }, + "client.Nickname": { + "type": "object", + "properties": { + "family_name": { + "type": "string" + }, + "given_name": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "client.SetUsernameResponse": { "type": "object", "properties": { diff --git a/src/docs/swagger.json b/src/docs/swagger.json index f88883c..6841a16 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -2591,6 +2591,26 @@ } } }, + "client.ContactProfile": { + "type": "object", + "properties": { + "about": { + "type": "string" + }, + "given_name": { + "type": "string" + }, + "has_avatar": { + "type": "boolean" + }, + "last_updated_timestamp": { + "type": "integer" + }, + "lastname": { + "type": "string" + } + } + }, "client.GroupEntry": { "type": "object", "properties": { @@ -2667,15 +2687,27 @@ "color": { "type": "string" }, + "given_name": { + "type": "string" + }, "message_expiration": { "type": "string" }, "name": { "type": "string" }, + "nickname": { + "$ref": "#/definitions/client.Nickname" + }, + "note": { + "type": "string" + }, "number": { "type": "string" }, + "profile": { + "$ref": "#/definitions/client.ContactProfile" + }, "profile_name": { "type": "string" }, @@ -2707,6 +2739,20 @@ } } }, + "client.Nickname": { + "type": "object", + "properties": { + "family_name": { + "type": "string" + }, + "given_name": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "client.SetUsernameResponse": { "type": "object", "properties": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index b6ecf1d..2d46d3a 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -309,6 +309,19 @@ definitions: type: string type: array type: object + client.ContactProfile: + properties: + about: + type: string + given_name: + type: string + has_avatar: + type: boolean + last_updated_timestamp: + type: integer + lastname: + type: string + type: object client.GroupEntry: properties: admins: @@ -359,12 +372,20 @@ definitions: type: boolean color: type: string + given_name: + type: string message_expiration: type: string name: type: string + nickname: + $ref: '#/definitions/client.Nickname' + note: + type: string number: type: string + profile: + $ref: '#/definitions/client.ContactProfile' profile_name: type: string username: @@ -385,6 +406,15 @@ definitions: url: type: string type: object + client.Nickname: + properties: + family_name: + type: string + given_name: + type: string + name: + type: string + type: object client.SetUsernameResponse: properties: username: