public IObservable<Event<ContactAggregateUpdate>> GetContactUpdates(User user, int versionId)
 {
     var streamName = ContactStreamNames.UserContacts(user.Id);
     return _eventStoreClient.GetEvents(streamName, versionId)
         .Where(resolvedEvent => resolvedEvent.OriginalEvent != null)
         .Select(resolvedEvent => new Event<ContactAggregateUpdate>(resolvedEvent.OriginalEventNumber, resolvedEvent.OriginalEvent.Deserialize<ContactAggregateUpdate>()));
 }
        public IObservable<int> ObserveContactUpdatesHeadVersion(User user)
        {
            var streamName = ContactStreamNames.UserContacts(user.Id);

            return Observable.Concat(
                _eventStoreClient.GetHeadVersion(streamName).ToObservable(),
                _eventStoreClient.GetNewEvents(streamName).Select(resolvedEvent => resolvedEvent.OriginalEventNumber));
        }
Ejemplo n.º 3
0
 public IObservable<IContactProfile> LookupContactByHandles(User user, ContactHandle[] contactHandles)
 {
     var keys = contactHandles.SelectMany(ch => ch.NormalizedHandle())
         .ToArray();
     var matchedContacts = _userContactMap[user.Id].GetByContactKeys(keys);
     //HACK: This should be able to return multiple values. -LC
     return matchedContacts.ToObservable();
 }
 public IObservable<IContactProfile> LookupContactByHandles(User user, ContactHandle[] contactHandles)
 {
     var keys = contactHandles.SelectMany(ch => ch.NormalizedHandle())
         .ToArray();
     return GetContactLookupFor(user)
         .Log(_logger, "GetContactDetails")
         .SelectMany(cl => cl.GetByContactKeys(keys));
 }
 private static IEnumerable<IAccount> GetAuthorizedGMailAccounts(User user)
 {
     //TODO: Enable the getting of a new token, and persisting it to the ES -LC
     return user.Accounts
         .Where(acc => !acc.CurrentSession.HasExpired())
         .Where(acc => acc.Provider == Constants.ProviderName)
         .Where(acc => acc.CurrentSession.AuthorizedResources.Contains(ResourceScope.Gmail.Resource));
 }
        public IObservable<IMessage> GetMessages(User user, string[] contactKeys)
        {
            if(user==null)throw new ArgumentNullException("user");
            if (contactKeys == null) throw new ArgumentNullException("contactKeys");
            if (contactKeys.Length == 0) 
                return Observable.Empty<IMessage>();

            return GetAuthorizedGMailAccounts(user)
                .Select(acc => SearchImap(contactKeys, acc))
                .Merge()
                .Log(_logger, "LoadMessages");
        }
 private IObservable<ContactLookup> GetContactLookupFor(User user)
 {
     var streamName = ContactStreamNames.UserContacts(user.Id);
     var query =
         from headVer in _eventStoreClient.GetHeadVersion(streamName).ToObservable()
                 .Log(_logger, "UserContact-Head")
         from contactUpdate in _eventStoreClient.GetEvents(streamName)
             .Where(resolvedEvent => resolvedEvent.OriginalEvent != null)
             .TakeUntil(re => re.OriginalEventNumber == headVer)
             .Select(resolvedEvent => resolvedEvent.OriginalEvent.Deserialize<ContactAggregateUpdate>())
             .Where(x => x != null)
             .Log(_logger, "UserContact-Profile")
         select contactUpdate;
     return query.Aggregate(new ContactLookup(), (acc, cur) => acc.Add(cur))
                 .Log(_logger, "UserContact-Aggregate");
 }
Ejemplo n.º 8
0
 private void SetPrincipal(User user, int version = 1)
 {
     var authTicket = new FormsAuthenticationTicket(version, user.DisplayName, 
         DateTime.UtcNow, DateTime.MaxValue, true, user.Id.ToString(), "CallWallAuth");
     
     var encTicket = FormsAuthentication.Encrypt(authTicket);
     var faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
     Response.Cookies.Add(faCookie);
 }
 public IObservable<IContactProfile> GetContactDetails(User user, string[] contactKeys)
 {
     //return Observable.Empty<IContactProfile>();
     return Observable.Interval(TimeSpan.FromSeconds(1))
                      .Zip(Profiles(), (_, msg) => msg);
 }
Ejemplo n.º 10
0
 public async Task When_user_adds_account()
 {
     _updatedUser = await UserRepository.RegisterAccount(_initialUser.Id, _newAccount);
 }
Ejemplo n.º 11
0
 public async Task Given_a_signed_in_user()
 {
     await UserRepository.Run();
     await UserRepository.Login(_initialAccount);
     _initialUser = await _userRepository.Login(_initialAccount);
 }
 public async Task When_a_user_registers_an_account()
 {
     _updatedUser = await _userRepository.RegisterAccount(_initialUser.Id, _newAccount);
     Trace.WriteLine("User registered additional account of " + _newAccount.AccountId);
 }
 public IObservable<IContactProfile> GetContactDetails(User user, string contactId)
 {
     return GetContactLookupFor(user).Select(cl => cl.GetById(int.Parse(contactId)));
 }
 public async Task When_a_user_registers_and_triggers_an_AccountRefresh()
 {
     User = await _userRepository.Login(_account);
 }
Ejemplo n.º 15
0
 private async Task RequestAccountRefresh(User user, ContactRefreshTriggers triggeredBy)
 {
     Logger.Trace("Requesting account refresh for userId {0}", user.Id);
     await Task.WhenAll(
         user.Accounts.Select(account =>
             _accountContactRefresher.RequestRefresh(user.Id, account, triggeredBy)
         ));
 }
 public async Task When_the_user_registers_with_an_unrecongised_account()
 {
     _user = await _userRepository.Login(_account);
 }
Ejemplo n.º 17
0
 private async Task RequestAccountRefreshForAllUserAccounts(User user, ContactRefreshTriggers triggeredBy)
 {
     Logger.Trace("Requesting account refresh for userId {0}", user.Id);
     await Task.Factory.StartNew(() =>
         {
             foreach (var acc in user.Accounts)
             {
                 RequestAccountRefresh(user.Id, triggeredBy, acc);
             }
         });
 }
 public void Given_an_anon_user()
 {
     _user = User.AnonUser;
 }
 public async Task When_user_logs_in_by_account()
 {
     _storedUser = await _userRepository.Login(_account);
 }
 public IObservable<IContactCollaboration> GetCollaborations(User user, string[] contactKeys)
 {
     return Observable.Interval(TimeSpan.FromSeconds(1))
         .Zip(GetContactCollaborations(), (_, msg) => msg);
 }
 public async Task Given_a_signed_in_user()
 {
     _initialUser = await _userRepository.Login(_initialAccount);
     Trace.WriteLine("User logged in with Account " + _initialAccount.AccountId);
 }
 public IObservable<ICalendarEntry> GetCalendarEntries(User user, string[] contactKeys)
 {
     return Observable.Interval(TimeSpan.FromSeconds(1))
         .Zip(GetCalendarEvents(), (_, msg) => msg);
 }
 public async Task When_a_user_registers_and_triggers_an_AccountRefresh()
 {
     _user = await _userRepository.Login(_account);
     Trace.WriteLine("Account logged in");
 }
Ejemplo n.º 24
0
 public IObservable<int> ObserveContactUpdatesHeadVersion(User user)
 {
     _logger.Trace("ObserveContactUpdatesHeadVersion({0})", user.Id);
     return _userContactsMap[user.Id].HeadEventId;
 }
 public IObservable<IContactProfile> GetContactDetails(User user, string[] contactKeys)
 {
     //TODO: Implement LinkedIn GetContactDetails
     return Observable.Empty<IContactProfile>();
 }
Ejemplo n.º 26
0
 public IObservable<Event<ContactAggregateUpdate>> GetContactUpdates(User user, int fromEventId)
 {
     _logger.Trace("GetContactUpdates({0}, {1})", user.Id, fromEventId);
     return _userContactsMap[user.Id].ContactUpdates.Where(evt => evt.EventId >= fromEventId);
 }
 public IObservable<IGalleryAlbum> GetGalleryAlbums(User user, string[] contactKeys)
 {
     return Observable.Interval(TimeSpan.FromSeconds(1))
         .Zip(GetAlbums(), (_, msg) => msg);
 }
Ejemplo n.º 28
0
 public IObservable<IContactProfile> GetContactDetails(User user, string contactId)
 {
     var contact = _userContactMap[user.Id].GetById(int.Parse(contactId));
     return Observable.Return(contact);
 }
Ejemplo n.º 29
0
        private void AddUserToCache(RecordedEvent recordedEvent)
        {
            var userCreatedEvent = recordedEvent.Deserialize<UserCreatedEvent>();
            var account = CreateAccount(userCreatedEvent.Account);
            var accounts = new[] { account };

            var user = new User(userCreatedEvent.Id, userCreatedEvent.DisplayName, accounts);
            _userCache.Add(user);
        }
 public IObservable<IMessage> GetMessages(User user, string[] contactKeys)
 {
     return Observable.Interval(TimeSpan.FromSeconds(1))
         .Zip(GetMessages(), (_, msg) => msg);
 }