(ctx context.Context, queryReason string)
| 674 | } |
| 675 | |
| 676 | func RetrieveAdditionalEntriesFromRemote(ctx context.Context, queryReason string) error { |
| 677 | db := hctx.GetDb(ctx) |
| 678 | config := hctx.GetConf(ctx) |
| 679 | if config.IsOffline { |
| 680 | return nil |
| 681 | } |
| 682 | respBody, err := ApiGet(ctx, "/api/v1/query?device_id="+config.DeviceId+"&user_id="+data.UserId(config.UserSecret)+"&queryReason="+queryReason) |
| 683 | if IsOfflineError(ctx, err) { |
| 684 | return nil |
| 685 | } |
| 686 | if err != nil { |
| 687 | return err |
| 688 | } |
| 689 | var retrievedEntries []*shared.EncHistoryEntry |
| 690 | err = json.Unmarshal(respBody, &retrievedEntries) |
| 691 | if err != nil { |
| 692 | return fmt.Errorf("failed to load JSON response: %w", err) |
| 693 | } |
| 694 | for _, entry := range retrievedEntries { |
| 695 | decEntry, err := data.DecryptHistoryEntry(config.UserSecret, *entry) |
| 696 | if err != nil { |
| 697 | return fmt.Errorf("failed to decrypt history entry from server: %w", err) |
| 698 | } |
| 699 | AddToDbIfNew(db, decEntry) |
| 700 | } |
| 701 | return ProcessDeletionRequests(ctx) |
| 702 | } |
| 703 | |
| 704 | func ProcessDeletionRequests(ctx context.Context) error { |
| 705 | config := hctx.GetConf(ctx) |
no test coverage detected