mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-19 15:44:28 +01:00
extended list contacts GET endpoint
* exposed some more fields see #675
This commit is contained in:
@@ -188,6 +188,20 @@ type ListInstalledStickerPacksResponse struct {
|
|||||||
Author string `json:"author"`
|
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 {
|
type ListContactsResponse struct {
|
||||||
Number string `json:"number"`
|
Number string `json:"number"`
|
||||||
Uuid string `json:"uuid"`
|
Uuid string `json:"uuid"`
|
||||||
@@ -197,6 +211,10 @@ type ListContactsResponse struct {
|
|||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Blocked bool `json:"blocked"`
|
Blocked bool `json:"blocked"`
|
||||||
MessageExpiration string `json:"message_expiration"`
|
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) {
|
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) {
|
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 {
|
type ListContactsSignlCliResponse struct {
|
||||||
Number string `json:"number"`
|
Number string `json:"number"`
|
||||||
Uuid string `json:"uuid"`
|
Uuid string `json:"uuid"`
|
||||||
@@ -2202,6 +2228,12 @@ func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, erro
|
|||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Blocked bool `json:"blocked"`
|
Blocked bool `json:"blocked"`
|
||||||
MessageExpiration string `json:"messageExpiration"`
|
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{}
|
resp := []ListContactsResponse{}
|
||||||
@@ -2229,11 +2261,12 @@ func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, erro
|
|||||||
var signalCliResp []ListContactsSignlCliResponse
|
var signalCliResp []ListContactsSignlCliResponse
|
||||||
err = json.Unmarshal([]byte(rawData), &signalCliResp)
|
err = json.Unmarshal([]byte(rawData), &signalCliResp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("Couldn't list contacts", err.Error())
|
||||||
return resp, errors.New("Couldn't process request - invalid signal-cli response")
|
return resp, errors.New("Couldn't process request - invalid signal-cli response")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range signalCliResp {
|
for _, value := range signalCliResp {
|
||||||
resp = append(resp, ListContactsResponse{
|
entry := ListContactsResponse{
|
||||||
Number: value.Number,
|
Number: value.Number,
|
||||||
Uuid: value.Uuid,
|
Uuid: value.Uuid,
|
||||||
Name: value.Name,
|
Name: value.Name,
|
||||||
@@ -2242,7 +2275,18 @@ func (s *SignalClient) ListContacts(number string) ([]ListContactsResponse, erro
|
|||||||
Color: value.Color,
|
Color: value.Color,
|
||||||
Blocked: value.Blocked,
|
Blocked: value.Blocked,
|
||||||
MessageExpiration: value.MessageExpiration,
|
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
|
return resp, nil
|
||||||
|
|||||||
@@ -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": {
|
"client.GroupEntry": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -2670,15 +2690,27 @@ const docTemplate = `{
|
|||||||
"color": {
|
"color": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"given_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"message_expiration": {
|
"message_expiration": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"nickname": {
|
||||||
|
"$ref": "#/definitions/client.Nickname"
|
||||||
|
},
|
||||||
|
"note": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"profile": {
|
||||||
|
"$ref": "#/definitions/client.ContactProfile"
|
||||||
|
},
|
||||||
"profile_name": {
|
"profile_name": {
|
||||||
"type": "string"
|
"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": {
|
"client.SetUsernameResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -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": {
|
"client.GroupEntry": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -2667,15 +2687,27 @@
|
|||||||
"color": {
|
"color": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"given_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"message_expiration": {
|
"message_expiration": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"nickname": {
|
||||||
|
"$ref": "#/definitions/client.Nickname"
|
||||||
|
},
|
||||||
|
"note": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"profile": {
|
||||||
|
"$ref": "#/definitions/client.ContactProfile"
|
||||||
|
},
|
||||||
"profile_name": {
|
"profile_name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -2707,6 +2739,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"client.Nickname": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"family_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"given_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"client.SetUsernameResponse": {
|
"client.SetUsernameResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -309,6 +309,19 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
type: object
|
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:
|
client.GroupEntry:
|
||||||
properties:
|
properties:
|
||||||
admins:
|
admins:
|
||||||
@@ -359,12 +372,20 @@ definitions:
|
|||||||
type: boolean
|
type: boolean
|
||||||
color:
|
color:
|
||||||
type: string
|
type: string
|
||||||
|
given_name:
|
||||||
|
type: string
|
||||||
message_expiration:
|
message_expiration:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
nickname:
|
||||||
|
$ref: '#/definitions/client.Nickname'
|
||||||
|
note:
|
||||||
|
type: string
|
||||||
number:
|
number:
|
||||||
type: string
|
type: string
|
||||||
|
profile:
|
||||||
|
$ref: '#/definitions/client.ContactProfile'
|
||||||
profile_name:
|
profile_name:
|
||||||
type: string
|
type: string
|
||||||
username:
|
username:
|
||||||
@@ -385,6 +406,15 @@ definitions:
|
|||||||
url:
|
url:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
client.Nickname:
|
||||||
|
properties:
|
||||||
|
family_name:
|
||||||
|
type: string
|
||||||
|
given_name:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
client.SetUsernameResponse:
|
client.SetUsernameResponse:
|
||||||
properties:
|
properties:
|
||||||
username:
|
username:
|
||||||
|
|||||||
Reference in New Issue
Block a user