@@ -230,12 +230,8 @@ type GhostKeyRequest struct {
230230 Hint string `json:"hint"`
231231}
232232
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 )
239235 if err != nil {
240236 return nil , err
241237 }
@@ -245,8 +241,8 @@ func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint stri
245241 return nil , ServerError (ctx , err )
246242 }
247243 var resp struct {
248- Data * GhostKeys `json:"data"`
249- Error Error `json:"error"`
244+ Data [] * GhostKeys `json:"data"`
245+ Error Error `json:"error"`
250246 }
251247 err = json .Unmarshal (body , & resp )
252248 if err != nil {
@@ -257,3 +253,18 @@ func ReadGhostKeys(ctx context.Context, receivers []string, index int, hint stri
257253 }
258254 return resp .Data , nil
259255}
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