@@ -122,6 +122,7 @@ type IdentityEntry struct {
122122 Fingerprint string `json:"fingerprint"`
123123 Added string `json:"added"`
124124 SafetyNumber string `json:"safety_number"`
125+ Uuid string `json:"uuid"`
125126}
126127
127128type SignalCliGroupMember struct {
@@ -1561,47 +1562,38 @@ func (s *SignalClient) UpdateProfile(number string, profileName string, base64Av
15611562}
15621563
15631564func (s * SignalClient ) ListIdentities (number string ) (* []IdentityEntry , error ) {
1565+ var err error
1566+ var rawData string
15641567 identityEntries := []IdentityEntry {}
15651568 if s .signalCliMode == JsonRpc {
15661569 jsonRpc2Client , err := s .getJsonRpc2Client ()
15671570 if err != nil {
15681571 return nil , err
15691572 }
1570- rawData , err := jsonRpc2Client .getRaw ("listIdentities" , & number , nil )
1571- signalCliIdentityEntries := []SignalCliIdentityEntry {}
1572- err = json .Unmarshal ([]byte (rawData ), & signalCliIdentityEntries )
1573- if err != nil {
1574- return nil , err
1575- }
1576- for _ , signalCliIdentityEntry := range signalCliIdentityEntries {
1577- identityEntry := IdentityEntry {
1578- Number : signalCliIdentityEntry .Number ,
1579- Status : signalCliIdentityEntry .TrustLevel ,
1580- Added : strconv .FormatInt (signalCliIdentityEntry .AddedTimestamp , 10 ),
1581- Fingerprint : signalCliIdentityEntry .Fingerprint ,
1582- SafetyNumber : signalCliIdentityEntry .SafetyNumber ,
1583- }
1584- identityEntries = append (identityEntries , identityEntry )
1585- }
1573+ rawData , err = jsonRpc2Client .getRaw ("listIdentities" , & number , nil )
15861574 } else {
1587- rawData , err := s .cliClient .Execute (true , []string {"--config" , s .signalCliConfig , "-a" , number , "listIdentities" }, "" )
1588- if err != nil {
1589- return nil , err
1590- }
1575+ rawData , err = s .cliClient .Execute (true , []string {"--config" , s .signalCliConfig , "-o" , "json" , "-a" , number , "listIdentities" }, "" )
1576+ }
15911577
1592- keyValuePairs := parseWhitespaceDelimitedKeyValueStringList (rawData , []string {"NumberAndTrustStatus" , "Added" , "Fingerprint" , "Safety Number" })
1593- for _ , keyValuePair := range keyValuePairs {
1594- numberAndTrustStatus := keyValuePair ["NumberAndTrustStatus" ]
1595- numberAndTrustStatusSplitted := strings .Split (numberAndTrustStatus , ":" )
1578+ if err != nil {
1579+ return nil , err
1580+ }
15961581
1597- identityEntry := IdentityEntry {Number : strings .Trim (numberAndTrustStatusSplitted [0 ], " " ),
1598- Status : strings .Trim (numberAndTrustStatusSplitted [1 ], " " ),
1599- Added : keyValuePair ["Added" ],
1600- Fingerprint : strings .Trim (keyValuePair ["Fingerprint" ], " " ),
1601- SafetyNumber : strings .Trim (keyValuePair ["Safety Number" ], " " ),
1602- }
1603- identityEntries = append (identityEntries , identityEntry )
1582+ signalCliIdentityEntries := []SignalCliIdentityEntry {}
1583+ err = json .Unmarshal ([]byte (rawData ), & signalCliIdentityEntries )
1584+ if err != nil {
1585+ return nil , err
1586+ }
1587+ for _ , signalCliIdentityEntry := range signalCliIdentityEntries {
1588+ identityEntry := IdentityEntry {
1589+ Number : signalCliIdentityEntry .Number ,
1590+ Status : signalCliIdentityEntry .TrustLevel ,
1591+ Added : strconv .FormatInt (signalCliIdentityEntry .AddedTimestamp , 10 ),
1592+ Fingerprint : signalCliIdentityEntry .Fingerprint ,
1593+ SafetyNumber : signalCliIdentityEntry .SafetyNumber ,
1594+ Uuid : signalCliIdentityEntry .Uuid ,
16041595 }
1596+ identityEntries = append (identityEntries , identityEntry )
16051597 }
16061598
16071599 return & identityEntries , nil
0 commit comments