コード例 #1
0
        public async Task HandleSeenAsync(TrackingToken token)
        {
            using (Telemetry.Activities.StartActivity("MobilePushChannel/HandleSeenAsync"))
            {
                var mobileToken = token.DeviceIdentifier;

                if (string.IsNullOrWhiteSpace(mobileToken))
                {
                    return;
                }

                var notification = await userNotificationStore.FindAsync(token.Id);

                if (notification == null)
                {
                    return;
                }

                var user = await userStore.GetCachedAsync(notification.AppId, notification.UserId);

                if (user == null)
                {
                    return;
                }

                var userToken = user.MobilePushTokens.FirstOrDefault(x => x.Token == mobileToken && x.DeviceType == MobileDeviceType.iOS);

                if (userToken != null)
                {
                    await TryWakeupAsync(notification, userToken, default);
                }
            }
        }
コード例 #2
0
        public async Task <IActionResult> Confirm(string id, [FromQuery] string?channel = null, [FromQuery] string?deviceIdentifier = null)
        {
            var token = TrackingToken.Parse(id, channel, deviceIdentifier);

            await userNotificationService.TrackConfirmedAsync(token);

            var notification = await userNotificationStore.FindAsync(token.Id, HttpContext.RequestAborted);

            if (notification == null)
            {
                return(View());
            }

            var app = await appStore.GetCachedAsync(notification.AppId, HttpContext.RequestAborted);

            if (app?.ConfirmUrl != null && Uri.IsWellFormedUriString(app.ConfirmUrl, UriKind.Absolute))
            {
                var url = app.ConfirmUrl !;

                if (url.Contains('?', StringComparison.OrdinalIgnoreCase))
                {
                    url += $"&id={id:notEmpty}";
                }
                else
                {
                    url += $"?id={id:notEmpty}";
                }

                return(Redirect(url));
            }

            return(View());
        }
コード例 #3
0
        public async Task <UserNotification?> TrackConfirmedAsync(TrackingToken token, Instant now,
                                                                  CancellationToken ct = default)
        {
            using (Telemetry.Activities.StartActivity("MongoDbUserNotificationRepository/TrackConfirmedAsync"))
            {
                await TrackSeenAsync(Enumerable.Repeat(token, 1), now, ct);

                var handle = new HandledInfo(now, token.Channel);

                var entity =
                    await Collection.FindOneAndUpdateAsync(
                        Filter.And(
                            Filter.Eq(x => x.Id, token.Id),
                            Filter.Eq(x => x.Formatting.ConfirmMode, ConfirmMode.Explicit),
                            Filter.Exists(x => x.FirstConfirmed, false)),
                        Update
                        .Set(x => x.FirstConfirmed, handle).Max(x => x.Updated, handle.Timestamp),
                        cancellationToken : ct);

                if (entity != null)
                {
                    if (entity.FirstConfirmed == null)
                    {
                        entity.FirstConfirmed = handle;
                    }

                    entity.Updated = handle.Timestamp;
                }

                return(entity);
            }
        }
コード例 #4
0
        public Task <UserNotification?> TrackConfirmedAsync(TrackingToken token,
                                                            CancellationToken ct = default)
        {
            Guard.NotDefault(token);

            return(repository.TrackConfirmedAsync(token, clock.GetCurrentInstant(), ct));
        }
コード例 #5
0
 public FunctionBlock(IBlock parent, BlockType type, TrackingToken start, ITextSnapshot textSnapshot, FunctionToken name)
     : base(parent, type, start, textSnapshot)
 {
     Name       = name;
     Parameters = new List <IDefinitionToken>();
     parent.AddToken(name);
     name.FunctionBlock = this;
 }
コード例 #6
0
        public async Task <IActionResult> ConfirmPost(string id, [FromQuery] string?channel = null, [FromQuery] string?deviceIdentifier = null)
        {
            var token = TrackingToken.Parse(id, channel, deviceIdentifier);

            await userNotificationService.TrackConfirmedAsync(token);

            return(NoContent());
        }
コード例 #7
0
        public async Task <IActionResult> Delivered(string id, [FromQuery] string?channel = null, [FromQuery] string?deviceIdentifier = null)
        {
            var tokens = Enumerable.Repeat(TrackingToken.Parse(id, channel, deviceIdentifier), 1);

            await userNotificationService.TrackDeliveredAsync(tokens);

            return(TrackingPixel());
        }
コード例 #8
0
        public void Should_parse_and_override_channel_and_device_identifier_if_not_set()
        {
            var sourceToken  = new TrackingToken(Guid.NewGuid());
            var sourceString = sourceToken.ToParsableString();

            var result = TrackingToken.Parse(sourceString, "push", "123");

            Assert.Equal(result, new TrackingToken(sourceToken.Id, "push", "123"));
        }
コード例 #9
0
        public void Should_parse_from_formatted_token_with_complex_device_identifier()
        {
            var sourceToken  = new TrackingToken(Guid.NewGuid(), "web", "a|very|complex|token");
            var sourceString = sourceToken.ToParsableString();

            var result = TrackingToken.Parse(sourceString);

            Assert.Equal(result, sourceToken);
        }
コード例 #10
0
        public void Should_parse_from_formatted_token_without_channel()
        {
            var sourceToken  = new TrackingToken(Guid.NewGuid());
            var sourceString = sourceToken.ToParsableString();

            var result = TrackingToken.Parse(sourceString);

            Assert.Equal(result, sourceToken);
        }
コード例 #11
0
        public async Task TrackConfirmedAsync(TrackingToken token)
        {
            if (!token.IsValid)
            {
                return;
            }

            await confirmProducer.ProduceAsync(token.ToString(), new ConfirmMessage { Token = token });
        }
コード例 #12
0
        public void Should_not_override_channel_device_identifier()
        {
            var sourceToken  = new TrackingToken(Guid.NewGuid(), "push", "123");
            var sourceString = sourceToken.ToParsableString();

            var result = TrackingToken.Parse(sourceString, "web", "456");

            Assert.Equal(result, sourceToken);
        }
コード例 #13
0
        public void Should_parse_from_guid()
        {
            var sourceToken  = Guid.NewGuid();
            var sourceString = sourceToken.ToString();

            var result = TrackingToken.Parse(sourceString);

            Assert.Equal(result, new TrackingToken(sourceToken));
        }
コード例 #14
0
ファイル: Block.cs プロジェクト: vsrad/radeon-asm-tools
        public void SetEnd(int endPosition, TrackingToken endToken, ITextSnapshot snapshot)
        {
            if (_startPosition > endPosition)
            {
                return;
            }

            Scope = new Span(_startPosition, endPosition - _startPosition);
            Area  = new Span(Area.Start, endToken.GetEnd(snapshot) - Area.Start);
        }
コード例 #15
0
        public async Task <IActionResult> ConfirmMe([FromBody] TrackNotificationDto request)
        {
            if (request.Confirmed != null)
            {
                var token = TrackingToken.Parse(request.Confirmed, request.Channel, request.DeviceIdentifier);

                await userNotificationService.TrackConfirmedAsync(token);
            }

            if (request.Seen?.Length > 0)
            {
                var tokens = request.Seen.Select(x => TrackingToken.Parse(x, request.Channel, request.DeviceIdentifier));

                await userNotificationService.TrackSeenAsync(tokens);
            }

            return(NoContent());
        }
コード例 #16
0
        public async Task <IActionResult> GetMyPolling([FromBody] PollRequest request)
        {
            var requestToken = request.Token ?? default;

            if (requestToken != default)
            {
                requestToken = requestToken.Minus(Duration.FromSeconds(10));
            }

#pragma warning disable MA0040 // Flow the cancellation token
            if (request.Delivered?.Length > 0)
            {
                var tokens = request.Delivered.Select(x => TrackingToken.Parse(x));

                await userNotificationStore.TrackSeenAsync(tokens);
            }

            if (request.Seen?.Length > 0)
            {
                var tokens = request.Seen.Select(x => TrackingToken.Parse(x));

                await userNotificationStore.TrackSeenAsync(tokens);
            }

            foreach (var id in request.Confirmed.OrEmpty())
            {
                var token = TrackingToken.Parse(id);

                await userNotificationStore.TrackConfirmedAsync(token);
            }
#pragma warning restore MA0040 // Flow the cancellation token

            foreach (var id in request.Deleted.OrEmpty())
            {
                await userNotificationStore.DeleteAsync(id, HttpContext.RequestAborted);
            }

            var notifications = await userNotificationStore.QueryAsync(App.Id, UserId, DefaultQuery with {
                After = requestToken
            }, HttpContext.RequestAborted);
コード例 #17
0
ファイル: DocumentState.cs プロジェクト: whuthj/VisualRust
 private string GetTextAndMarkForRemoval(TrackingToken current, ref List<TrackingToken> removalCandidates)
 {
     removalCandidates.Add(current);
     Span span = current.GetSpan(CurrentSnapshot);
     if(span.End > CurrentSnapshot.Length)
         return null;
     return current.GetText(CurrentSnapshot);
 }
コード例 #18
0
 public override TaskInformation GetStatus(TrackingToken trackingToken)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
ファイル: Block.cs プロジェクト: vsrad/radeon-asm-tools
 public Block(IBlock parent, BlockType type, TrackingToken start, TrackingToken end, ITextSnapshot snapshot)
     : this(parent, type, start.GetStart(snapshot), end.GetEnd(snapshot))
 {
 }
コード例 #20
0
ファイル: Block.cs プロジェクト: vsrad/radeon-asm-tools
 public Block(IBlock parent, BlockType type, TrackingToken start, ITextSnapshot snapshot)
     : this(parent, type, start.GetStart(snapshot), snapshot.Length - 1)
 {
 }
コード例 #21
0
        public void Should_not_throw_if_null_or_empty(string value)
        {
            var result = TrackingToken.Parse(value);

            Assert.False(result.IsValid);
        }