Example #1
0
        public async Task <string> GetVariableAsync(string name, IContext context, CancellationToken cancellationToken)
        {
            var tunnel = await _tunnelExtension.TryGetTunnelAsync(context.Input.Message, cancellationToken);

            if (tunnel == null)
            {
                return(null);
            }

            return(GetVariable(name, tunnel, context.Input.Message.From.ToIdentity()));
        }
Example #2
0
        public async Task <UserOwner> GetUserOwnerIdentitiesAsync <T>(T envelope, BuilderConfiguration builderConfiguration, CancellationToken cancellationToken)
            where T : Envelope
        {
            if (envelope == null)
            {
                throw new ArgumentNullException(nameof(envelope));
            }
            if (envelope.From == null)
            {
                throw new ArgumentException("Envelope 'from' is required", nameof(envelope));
            }
            if (builderConfiguration == null)
            {
                throw new ArgumentNullException(nameof(builderConfiguration));
            }

            Identity userIdentity;
            Identity ownerIdentity;
            Tunnel   tunnel = null;

            if (builderConfiguration.UseTunnelOwnerContext == true)
            {
                tunnel = await _tunnelExtension.TryGetTunnelAsync(envelope, cancellationToken);
            }

            if (tunnel != null)
            {
                userIdentity  = tunnel.Originator.ToIdentity();
                ownerIdentity = tunnel.Owner;
            }
            else if (builderConfiguration.OwnerIdentity != null)
            {
                userIdentity  = envelope.From.ToIdentity();
                ownerIdentity = builderConfiguration.OwnerIdentity;
            }
            else
            {
                userIdentity  = envelope.From.ToIdentity();
                ownerIdentity = _applicationIdentity;
            }

            return(new UserOwner(userIdentity, ownerIdentity));
        }