@@ -230,12 +230,8 @@ type GhostKeyRequest struct {
230
230
Hint string `json:"hint"`
231
231
}
232
232
233
- func ReadGhostKeys (ctx context.Context , receivers []string , index int , hint string , uid , sid , sessionKey string ) (* GhostKeys , error ) {
234
- data , err := json .Marshal (map [string ]interface {}{
235
- "receivers" : receivers ,
236
- "index" : index ,
237
- "hint" : hint ,
238
- })
233
+ func ReadGhostKeys (ctx context.Context , gkr []GhostKeyRequest , uid , sid , sessionKey string ) ([]* GhostKeys , error ) {
234
+ data , err := json .Marshal (gkr )
239
235
if err != nil {
240
236
return nil , err
241
237
}
@@ -245,8 +241,8 @@ func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint stri
245
241
return nil , ServerError (ctx , err )
246
242
}
247
243
var resp struct {
248
- Data * GhostKeys `json:"data"`
249
- Error Error `json:"error"`
244
+ Data [] * GhostKeys `json:"data"`
245
+ Error Error `json:"error"`
250
246
}
251
247
err = json .Unmarshal (body , & resp )
252
248
if err != nil {
@@ -257,3 +253,18 @@ func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint stri
257
253
}
258
254
return resp .Data , nil
259
255
}
256
+
257
+ func ReadGhostKey (ctx context.Context , receivers []string , index int , hint string , uid , sid , sessionKey string ) (* GhostKeys , error ) {
258
+ r := GhostKeyRequest {
259
+ Receivers : receivers ,
260
+ Index : index ,
261
+ Hint : hint ,
262
+ }
263
+
264
+ result , err := ReadGhostKeys (ctx , []GhostKeyRequest {r }, uid , sid , sessionKey )
265
+ if err != nil {
266
+ return nil , err
267
+ }
268
+
269
+ return result [0 ], nil
270
+ }
0 commit comments