/// <inheritdoc /> public virtual async Task <string> AcceptInvitationAsync(Wallet wallet, ConnectionInvitationMessage invitation) { Logger.LogInformation(LoggingEvents.AcceptInvitation, "Key {0}, Endpoint {1}", invitation.ConnectionKey, invitation.Endpoint.Uri); var my = await Did.CreateAndStoreMyDidAsync(wallet, "{}"); var connection = new ConnectionRecord { Endpoint = invitation.Endpoint, MyDid = my.Did, MyVk = my.VerKey, ConnectionId = Guid.NewGuid().ToString().ToLowerInvariant() }; connection.Tags.Add(TagConstants.MyDid, my.Did); if (!string.IsNullOrEmpty(invitation.Name) || !string.IsNullOrEmpty(invitation.ImageUrl)) { connection.Alias = new ConnectionAlias { Name = invitation.Name, ImageUrl = invitation.ImageUrl }; if (string.IsNullOrEmpty(invitation.Name)) { connection.Tags.Add(TagConstants.Alias, invitation.Name); } } await connection.TriggerAsync(ConnectionTrigger.InvitationAccept); await RecordService.AddAsync(wallet, connection); var provisioning = await ProvisioningService.GetProvisioningAsync(wallet); var connectionDetails = new ConnectionDetails { Did = my.Did, Verkey = my.VerKey, Endpoint = provisioning.Endpoint }; var request = await MessageSerializer.PackSealedAsync <ConnectionRequestMessage>(connectionDetails, wallet, my.VerKey, invitation.ConnectionKey); request.Key = invitation.ConnectionKey; request.Type = MessageUtils.FormatKeyMessageType(invitation.ConnectionKey, MessageTypes.ConnectionRequest); var forwardMessage = new ForwardToKeyEnvelopeMessage { Type = MessageUtils.FormatKeyMessageType(invitation.ConnectionKey, MessageTypes.ForwardToKey), Content = request.ToJson() }; await RouterService.ForwardAsync(forwardMessage, invitation.Endpoint); return(connection.GetId()); }
public async Task CanStoreAndRetrieveRecordWithTagsUsingSearch() { var tagName = Guid.NewGuid().ToString(); var tagValue = Guid.NewGuid().ToString(); var record = new ConnectionRecord { ConnectionId = Guid.NewGuid().ToString() }; record.Tags.Add(tagName, tagValue); await _recordService.AddAsync(_wallet, record); var search = await _recordService.SearchAsync <ConnectionRecord>(_wallet, new SearchRecordQuery() { { tagName, tagValue } }, null, 100); var retrieved = search.Single(); Assert.NotNull(retrieved); Assert.Equal(retrieved.GetId(), record.GetId()); Assert.True(retrieved.Tags.ContainsKey(tagName)); Assert.Equal(tagValue, retrieved.Tags[tagName]); }
public async Task CanUpdateRecordWithTags() { var tagName = Guid.NewGuid().ToString(); var tagValue = Guid.NewGuid().ToString(); var id = Guid.NewGuid().ToString(); var record = new ConnectionRecord { ConnectionId = id }; record.Tags.Add(tagName, tagValue); await _recordService.AddAsync(_wallet, record); var retrieved = await _recordService.GetAsync <ConnectionRecord>(_wallet, id); retrieved.MyDid = "123"; retrieved.Tags[tagName] = "value"; await _recordService.UpdateAsync(_wallet, retrieved); var updated = await _recordService.GetAsync <ConnectionRecord>(_wallet, id); Assert.NotNull(updated); Assert.Equal(updated.GetId(), record.GetId()); Assert.True(updated.Tags.ContainsKey(tagName)); Assert.Equal("value", updated.Tags[tagName]); Assert.Equal("123", updated.MyDid); }
public async Task CanStoreAndRetrieveRecordWithTags() { var record = new ConnectionRecord { ConnectionId = "123" }; record.Tags.Add("tag1", "tagValue1"); await _recordService.AddAsync(_wallet, record); var retrieved = await _recordService.GetAsync <ConnectionRecord>(_wallet, "123"); Assert.NotNull(retrieved); Assert.Equal(retrieved.GetId(), record.GetId()); Assert.True(retrieved.Tags.ContainsKey("tag1")); Assert.Equal("tagValue1", retrieved.Tags["tag1"]); }