/// <summary>
        /// Insert push registrations
        /// </summary>
        /// <param name="storageConsistencyMode">Consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="platformType">Platform type</param>
        /// <param name="registrationId">OS registration id</param>
        /// <param name="hubRegistrationId">Hub registration id</param>
        /// <param name="language">Client language</param>
        /// <param name="lastUpdatedTime">Last updated time</param>
        /// <returns>Insert push registration task</returns>
        public async Task InsertPushRegistration(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            string appHandle,
            PlatformType platformType,
            string registrationId,
            string hubRegistrationId,
            string language,
            DateTime lastUpdatedTime)
        {
            PushRegistrationFeedEntity entity = new PushRegistrationFeedEntity()
            {
                UserHandle        = userHandle,
                AppHandle         = appHandle,
                PlatformType      = platformType,
                OSRegistrationId  = registrationId,
                HubRegistrationId = hubRegistrationId,
                Language          = language,
                LastUpdatedTime   = lastUpdatedTime
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.PushRegistrations);

            FeedTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.PushRegistrations, TableIdentifier.PushRegistrationsFeed) as FeedTable;
            Operation operation = Operation.InsertOrReplace(table, userHandle, appHandle, registrationId, entity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
        /// <summary>
        /// Insert following activity
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="activityHandle">Activity handle</param>
        /// <param name="activityType">Activity type</param>
        /// <param name="actorUserHandle">Actor user handle</param>
        /// <param name="actedOnUserHandle">Acted on user handle</param>
        /// <param name="actedOnContentType">Acted on content type</param>
        /// <param name="actedOnContentHandle">Acted on content handle</param>
        /// <param name="createdTime">Created time</param>
        /// <returns>Insert activity task</returns>
        public async Task InsertFollowingActivity(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            string appHandle,
            string activityHandle,
            ActivityType activityType,
            string actorUserHandle,
            string actedOnUserHandle,
            ContentType actedOnContentType,
            string actedOnContentHandle,
            DateTime createdTime)
        {
            // Insert an activity into a user's following activities feed
            //
            // PartitionKey: UserHandle
            // FeedKey: AppHandle
            // ItemKey: ActivityHandle (reverse sorted by time). We use LikeHandle, CommentHandle, ReplyHandle, and RelationshipHandle as activity handles
            ActivityFeedEntity activityFeedEntity = new ActivityFeedEntity()
            {
                ActivityHandle       = activityHandle,
                AppHandle            = appHandle,
                ActivityType         = activityType,
                ActorUserHandle      = actorUserHandle,
                ActedOnUserHandle    = actedOnUserHandle,
                ActedOnContentType   = actedOnContentType,
                ActedOnContentHandle = actedOnContentHandle,
                CreatedTime          = createdTime
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.FollowingActivities);

            FeedTable feedTable = this.tableStoreManager.GetTable(ContainerIdentifier.FollowingActivities, TableIdentifier.FollowingActivitiesFeed) as FeedTable;
            Operation operation = Operation.InsertOrReplace(feedTable, userHandle, appHandle, activityHandle, activityFeedEntity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Insert a new user-generated report of another user into the store
        /// </summary>
        /// <param name="storageConsistencyMode">consistency to use</param>
        /// <param name="reportHandle">uniquely identifies this report</param>
        /// <param name="reportedUserHandle">uniquely identifies the user who is being reported</param>
        /// <param name="reportingUserHandle">uniquely identifies the user doing the reporting</param>
        /// <param name="appHandle">uniquely identifies the app that the user is in</param>
        /// <param name="reason">the complaint against the content</param>
        /// <param name="lastUpdatedTime">when the report was received</param>
        /// <param name="hasComplainedBefore">has the reporting user complained about this user before?</param>
        /// <returns>a task that inserts the report into the store</returns>
        public async Task InsertUserReport(
            StorageConsistencyMode storageConsistencyMode,
            string reportHandle,
            string reportedUserHandle,
            string reportingUserHandle,
            string appHandle,
            ReportReason reason,
            DateTime lastUpdatedTime,
            bool hasComplainedBefore)
        {
            // get all the table interfaces
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserReports);

            ObjectTable lookupTable               = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsLookup) as ObjectTable;
            ObjectTable lookupUniquenessTable     = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsLookupUniquenessByReportingUser) as ObjectTable;
            FeedTable   feedByAppTable            = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsRecentFeedByApp) as FeedTable;
            FeedTable   feedByReportedUserTable   = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsRecentFeedByReportedUser) as FeedTable;
            FeedTable   feedByReportingUserTable  = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsRecentFeedByReportingUser) as FeedTable;
            CountTable  countByReportedUserTable  = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsCountByReportedUser) as CountTable;
            CountTable  countByReportingUserTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsCountByReportingUser) as CountTable;

            // create the two entities that will be inserted into the tables
            UserReportEntity userReportEntity = new UserReportEntity()
            {
                ReportedUserHandle  = reportedUserHandle,
                ReportingUserHandle = reportingUserHandle,
                AppHandle           = appHandle,
                Reason      = reason,
                CreatedTime = lastUpdatedTime
            };

            UserReportFeedEntity userReportFeedEntity = new UserReportFeedEntity()
            {
                ReportHandle        = reportHandle,
                ReportedUserHandle  = reportedUserHandle,
                ReportingUserHandle = reportingUserHandle,
                AppHandle           = appHandle
            };

            // do the inserts and increments as a transaction
            Transaction transaction = new Transaction();

            // the partition key is app handle for all tables so that a transaction can be achieved
            transaction.Add(Operation.Insert(lookupTable, appHandle, reportHandle, userReportEntity));
            transaction.Add(Operation.Insert(feedByAppTable, appHandle, appHandle, reportHandle, userReportFeedEntity));
            transaction.Add(Operation.Insert(feedByReportedUserTable, appHandle, reportedUserHandle, reportHandle, userReportFeedEntity));
            transaction.Add(Operation.Insert(feedByReportingUserTable, appHandle, reportingUserHandle, reportHandle, userReportFeedEntity));

            // if the reporting user has not previously reported this user, then increment counts
            if (!hasComplainedBefore)
            {
                string uniquenessKey = UniquenessObjectKey(reportedUserHandle, reportingUserHandle);
                transaction.Add(Operation.Insert(lookupUniquenessTable, appHandle, uniquenessKey, new ObjectEntity()));
                transaction.Add(Operation.InsertOrIncrement(countByReportedUserTable, appHandle, reportedUserHandle));
                transaction.Add(Operation.InsertOrIncrement(countByReportingUserTable, appHandle, reportingUserHandle));
            }

            // execute the transaction
            await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update following relationship.
        /// Following user : someone who i am following.
        /// </summary>
        /// <param name="storageConsistencyMode">Consistency mode</param>
        /// <param name="relationshipHandle">Relationship handle</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="relationshipUserHandle">Relationship user handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="userRelationshipStatus">User relationship status</param>
        /// <param name="lastUpdatedTime">Last updated time</param>
        /// <param name="readUserRelationshipLookupEntity">Read user relationship lookup entity</param>
        /// <returns>Update following relationship task</returns>
        public async Task UpdateFollowingRelationship(
            StorageConsistencyMode storageConsistencyMode,
            string relationshipHandle,
            string userHandle,
            string relationshipUserHandle,
            string appHandle,
            UserRelationshipStatus userRelationshipStatus,
            DateTime lastUpdatedTime,
            IUserRelationshipLookupEntity readUserRelationshipLookupEntity)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserFollowing);

            ObjectTable lookupTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserFollowing, TableIdentifier.FollowingLookup) as ObjectTable;
            FeedTable   feedTable   = this.tableStoreManager.GetTable(ContainerIdentifier.UserFollowing, TableIdentifier.FollowingFeed) as FeedTable;
            CountTable  countTable  = this.tableStoreManager.GetTable(ContainerIdentifier.UserFollowing, TableIdentifier.FollowingCount) as CountTable;

            await this.UpdateUserRelationship(
                storageConsistencyMode,
                relationshipHandle,
                userHandle,
                relationshipUserHandle,
                appHandle,
                userRelationshipStatus,
                lastUpdatedTime,
                readUserRelationshipLookupEntity,
                store,
                lookupTable,
                feedTable,
                countTable);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Insert user topic
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <returns>Insert user topic task</returns>
        public async Task InsertUserTopic(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            string appHandle,
            string topicHandle)
        {
            TopicFeedEntity topicFeedEntity = new TopicFeedEntity()
            {
                AppHandle   = appHandle,
                TopicHandle = topicHandle,
                UserHandle  = userHandle
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserTopics);

            FeedTable  feedTable  = this.tableStoreManager.GetTable(ContainerIdentifier.UserTopics, TableIdentifier.UserTopicsFeed) as FeedTable;
            CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserTopics, TableIdentifier.UserTopicsCount) as CountTable;

            Transaction transaction = new Transaction();

            transaction.Add(Operation.Insert(feedTable, userHandle, appHandle, topicHandle, topicFeedEntity));
            transaction.Add(Operation.Insert(feedTable, userHandle, MasterApp.AppHandle, topicHandle, topicFeedEntity));
            transaction.Add(Operation.InsertOrIncrement(countTable, userHandle, appHandle));
            transaction.Add(Operation.InsertOrIncrement(countTable, userHandle, MasterApp.AppHandle));
            await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode());
        }
        /// <summary>
        /// Query notification
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="activityHandle">Activity handle</param>
        /// <returns>Activity feed entity</returns>
        public async Task <IActivityFeedEntity> QueryNotification(string userHandle, string appHandle, string activityHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Notifications);

            FeedTable table = this.tableStoreManager.GetTable(ContainerIdentifier.Notifications, TableIdentifier.NotificationsFeed) as FeedTable;

            return(await store.QueryFeedItemAsync <ActivityFeedEntity>(table, userHandle, appHandle, activityHandle));
        }
        /// <summary>
        /// Query following activities
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>Activity feed entities</returns>
        public async Task <IList <IActivityFeedEntity> > QueryFollowingActivities(string userHandle, string appHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.FollowingActivities);

            FeedTable table  = this.tableStoreManager.GetTable(ContainerIdentifier.FollowingActivities, TableIdentifier.FollowingActivitiesFeed) as FeedTable;
            var       result = await store.QueryFeedAsync <ActivityFeedEntity>(table, userHandle, appHandle, cursor, limit);

            return(result.ToList <IActivityFeedEntity>());
        }
        /// <summary>
        /// Query topic comments
        /// </summary>
        /// <param name="topicHandle">Topic handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>Comment feed entities</returns>
        public async Task <IList <ICommentFeedEntity> > QueryTopicComments(string topicHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.TopicComments);

            FeedTable table  = this.tableStoreManager.GetTable(ContainerIdentifier.TopicComments, TableIdentifier.TopicCommentsFeed) as FeedTable;
            var       result = await store.QueryFeedAsync <CommentFeedEntity>(table, topicHandle, this.tableStoreManager.DefaultFeedKey, cursor, limit);

            return(result.ToList <ICommentFeedEntity>());
        }
Exemplo n.º 9
0
        /// <summary>
        /// Query client name from ClientNamesFeed in AppKey container
        /// </summary>
        /// <param name="appKey">App key</param>
        /// <returns>Client names</returns>
        public async Task <IList <IClientNamesFeedEntity> > QueryClientNames(string appKey)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.AppKeys);

            FeedTable table  = this.tableStoreManager.GetTable(ContainerIdentifier.AppKeys, TableIdentifier.ClientNamesFeed) as FeedTable;
            var       result = await store.QueryFeedAsync <ClientNamesFeedEntity>(table, appKey, this.tableStoreManager.DefaultFeedKey, null, int.MaxValue);

            return(result.ToList <IClientNamesFeedEntity>());
        }
Exemplo n.º 10
0
        /// <summary>
        /// Query likes for a content
        /// </summary>
        /// <param name="contentHandle">Content handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>List of like feed entities</returns>
        public async Task <IList <ILikeFeedEntity> > QueryLikes(string contentHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Likes);

            FeedTable feedTable = this.tableStoreManager.GetTable(ContainerIdentifier.Likes, TableIdentifier.LikesFeed) as FeedTable;
            var       result    = await store.QueryFeedAsync <LikeFeedEntity>(feedTable, contentHandle, this.tableStoreManager.DefaultFeedKey, cursor, limit);

            return(result.ToList <ILikeFeedEntity>());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Query pins for a user in an app
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>List of pin feed entities</returns>
        public async Task <IList <IPinFeedEntity> > QueryPins(string userHandle, string appHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Pins);

            FeedTable feedTable = this.tableStoreManager.GetTable(ContainerIdentifier.Pins, TableIdentifier.PinsFeed) as FeedTable;
            var       result    = await store.QueryFeedAsync <PinFeedEntity>(feedTable, userHandle, appHandle, cursor, limit);

            return(result.ToList <IPinFeedEntity>());
        }
Exemplo n.º 12
0
        /// <summary>
        /// Query user apps
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <returns>Apps used by user</returns>
        public async Task <IList <IAppFeedEntity> > QueryUserApps(string userHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users);

            FeedTable indexTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserAppsFeed) as FeedTable;
            var       result     = await store.QueryFeedAsync <AppFeedEntity>(indexTable, userHandle, this.tableStoreManager.DefaultFeedKey, null, int.MaxValue);

            return(result.ToList <IAppFeedEntity>());
        }
Exemplo n.º 13
0
        /// <summary>
        /// Query featured topics
        /// </summary>
        /// <param name="appHandle">App handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>Topic feed entities</returns>
        public async Task <IList <ITopicFeedEntity> > QueryFeaturedTopics(string appHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.FeaturedTopics);

            FeedTable table  = this.tableStoreManager.GetTable(ContainerIdentifier.FeaturedTopics, TableIdentifier.FeaturedTopicsFeed) as FeedTable;
            var       result = await store.QueryFeedAsync <TopicFeedEntity>(table, ContainerIdentifier.FeaturedTopics.ToString(), appHandle, cursor, limit);

            return(result.ToList <ITopicFeedEntity>());
        }
Exemplo n.º 14
0
        /// <summary>
        /// Query all apps
        /// </summary>
        /// <returns>App feed entities</returns>
        public async Task <IList <IAppFeedEntity> > QueryAllApps()
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.AllApps);

            FeedTable table  = this.tableStoreManager.GetTable(ContainerIdentifier.AllApps, TableIdentifier.AllAppsFeed) as FeedTable;
            var       result = await store.QueryFeedAsync <AppFeedEntity>(table, ContainerIdentifier.AllApps.ToString(), this.tableStoreManager.DefaultFeedKey, null, int.MaxValue);

            return(result.ToList <IAppFeedEntity>());
        }
Exemplo n.º 15
0
        /// <summary>
        /// Query blocked users for a user in an app
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>List of user relationship feed entities</returns>
        public async Task <IList <IUserRelationshipFeedEntity> > QueryBlockedUsers(string userHandle, string appHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserFollowers);

            FeedTable feedTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserFollowers, TableIdentifier.FollowersFeed) as FeedTable;
            string    feedKey   = this.GetFeedKey(appHandle, UserRelationshipStatus.Blocked);
            var       result    = await store.QueryFeedAsync <UserRelationshipFeedEntity>(feedTable, userHandle, feedKey, cursor, limit);

            return(result.ToList <IUserRelationshipFeedEntity>());
        }
Exemplo n.º 16
0
        /// <summary>
        /// Delete all app
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="appHandle">App handle</param>
        /// <returns>Delete all app task</returns>
        public async Task DeleteAllApp(
            StorageConsistencyMode storageConsistencyMode,
            string appHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.AllApps);

            FeedTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.AllApps, TableIdentifier.AllAppsFeed) as FeedTable;
            Operation operation = Operation.Delete(table, ContainerIdentifier.AllApps.ToString(), this.tableStoreManager.DefaultFeedKey, appHandle);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 17
0
        /// <summary>
        /// Query linked account
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="identityProviderType">Identity provider type</param>
        /// <returns>Linked account entity</returns>
        public async Task <ILinkedAccountFeedEntity> QueryLinkedAccount(
            string userHandle,
            IdentityProviderType identityProviderType)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users);

            FeedTable accountsTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserLinkedAccountsFeed) as FeedTable;

            return(await store.QueryFeedItemAsync <LinkedAccountFeedEntity>(accountsTable, userHandle, this.tableStoreManager.DefaultFeedKey, identityProviderType.ToString()));
        }
        /// <summary>
        /// Query topic following in an app.
        /// Following topics : topics that i am following.
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>List of topic relationship feed entities</returns>
        public async Task <IList <ITopicRelationshipFeedEntity> > QueryTopicFollowing(string userHandle, string appHandle, string cursor, int limit)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.TopicFollowing);

            FeedTable feedTable = this.tableStoreManager.GetTable(ContainerIdentifier.TopicFollowing, TableIdentifier.TopicFollowingFeed) as FeedTable;
            string    feedKey   = this.GetFeedKey(appHandle, TopicRelationshipStatus.Follow);
            var       result    = await store.QueryFeedAsync <TopicRelationshipFeedEntity>(feedTable, userHandle, feedKey, cursor, limit);

            return(result.ToList <ITopicRelationshipFeedEntity>());
        }
Exemplo n.º 19
0
        /// <summary>
        /// Delete client name from ClientNamesFeed in AppKey container
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="appKey">App key</param>
        /// <param name="clientName">Client name</param>
        /// <returns>Delete client name from its feed</returns>
        public async Task DeleteClientName(
            StorageConsistencyMode storageConsistencyMode,
            string appKey,
            string clientName)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.AppKeys);

            FeedTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.AppKeys, TableIdentifier.ClientNamesFeed) as FeedTable;
            Operation operation = Operation.Delete(table, appKey, this.tableStoreManager.DefaultFeedKey, clientName);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
        /// <summary>
        /// Query push registration
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="registrationId">OS registration id</param>
        /// <returns>Push registration entities</returns>
        public async Task <IPushRegistrationFeedEntity> QueryPushRegistration(
            string userHandle,
            string appHandle,
            string registrationId)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.PushRegistrations);

            FeedTable table = this.tableStoreManager.GetTable(ContainerIdentifier.PushRegistrations, TableIdentifier.PushRegistrationsFeed) as FeedTable;

            return(await store.QueryFeedItemAsync <PushRegistrationFeedEntity>(table, userHandle, appHandle, registrationId));
        }
        /// <summary>
        /// Query push registrations
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <returns>Push registration entities</returns>
        public async Task <IList <IPushRegistrationFeedEntity> > QueryPushRegistrations(
            string userHandle,
            string appHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.PushRegistrations);

            FeedTable table  = this.tableStoreManager.GetTable(ContainerIdentifier.PushRegistrations, TableIdentifier.PushRegistrationsFeed) as FeedTable;
            var       result = await store.QueryFeedAsync <PushRegistrationFeedEntity>(table, userHandle, appHandle, null, int.MaxValue);

            return(result.ToList <IPushRegistrationFeedEntity>());
        }
Exemplo n.º 22
0
        /// <summary>
        /// Delete linked account
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="identityProviderType">Identity provider type</param>
        /// <returns>Delete linked account task</returns>
        public async Task DeleteLinkedAccount(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            IdentityProviderType identityProviderType)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users);

            FeedTable accountsTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserLinkedAccountsFeed) as FeedTable;
            Operation operation     = Operation.Delete(accountsTable, userHandle, this.tableStoreManager.DefaultFeedKey, identityProviderType.ToString());
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
        /// <summary>
        /// Delete push registrations
        /// </summary>
        /// <param name="storageConsistencyMode">Consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="registrationId">OS registration id</param>
        /// <returns>Delete push registration task</returns>
        public async Task DeletePushRegistration(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            string appHandle,
            string registrationId)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.PushRegistrations);

            FeedTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.PushRegistrations, TableIdentifier.PushRegistrationsFeed) as FeedTable;
            Operation operation = Operation.Delete(table, userHandle, appHandle, registrationId);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 24
0
        /// <summary>
        /// Look up all the reports against users from a particular app
        /// </summary>
        /// <param name="appHandle">uniquely identifies the app</param>
        /// <param name="cursor">Read cursor</param>
        /// <param name="limit">Number of items to return</param>
        /// <returns>a task that returns a list of user reports</returns>
        public async Task <IList <IUserReportFeedEntity> > QueryUserReportsByApp(string appHandle, string cursor, int limit)
        {
            // get the table interface
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.UserReports);

            FeedTable feedByAppTable = this.tableStoreManager.GetTable(ContainerIdentifier.UserReports, TableIdentifier.UserReportsRecentFeedByApp) as FeedTable;

            // get the feed & return it
            var result = await store.QueryFeedAsync <UserReportFeedEntity>(feedByAppTable, appHandle, appHandle, cursor, limit);

            return(result.ToList <IUserReportFeedEntity>());
        }
        /// <summary>
        /// Insert notification
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="activityHandle">Activity handle</param>
        /// <param name="activityType">Activity type</param>
        /// <param name="actorUserHandle">Actor user handle</param>
        /// <param name="actedOnUserHandle">Acted on user handle</param>
        /// <param name="actedOnContentType">Acted on content type</param>
        /// <param name="actedOnContentHandle">Acted on content handle</param>
        /// <param name="createdTime">Created time</param>
        /// <returns>Insert notification task</returns>
        public async Task InsertNotification(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            string appHandle,
            string activityHandle,
            ActivityType activityType,
            string actorUserHandle,
            string actedOnUserHandle,
            ContentType actedOnContentType,
            string actedOnContentHandle,
            DateTime createdTime)
        {
            ActivityFeedEntity activityFeedEntity = new ActivityFeedEntity()
            {
                ActivityHandle       = activityHandle,
                AppHandle            = appHandle,
                ActivityType         = activityType,
                ActorUserHandle      = actorUserHandle,
                ActedOnUserHandle    = actedOnUserHandle,
                ActedOnContentType   = actedOnContentType,
                ActedOnContentHandle = actedOnContentHandle,
                CreatedTime          = createdTime
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Notifications);

            FeedTable  feedTable  = this.tableStoreManager.GetTable(ContainerIdentifier.Notifications, TableIdentifier.NotificationsFeed) as FeedTable;
            CountTable countTable = this.tableStoreManager.GetTable(ContainerIdentifier.Notifications, TableIdentifier.NotificationsCount) as CountTable;

            // do an insert & increment in a transaction.
            // if a queue message for inserting a notification gets processed twice, then this transaction will generate
            // a storage exception on the second attempt (because the insert will fail with a conflict (409) http status)
            try
            {
                Transaction transaction = new Transaction();
                transaction.Add(Operation.Insert(feedTable, userHandle, appHandle, activityHandle, activityFeedEntity));
                transaction.Add(Operation.InsertOrIncrement(countTable, userHandle, appHandle));
                await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode());
            }
            catch (StorageException e)
            {
                // ignore this exception only if item exists (error code 409 conflict)
                if (e.RequestInformation.HttpStatusCode == (int)HttpStatusCode.Conflict)
                {
                    this.log.LogInformation("NotificationsStore.InsertNotification received a conflict on insert" + e.Message);
                }
                else
                {
                    throw e;
                }
            }
        }
Exemplo n.º 26
0
        private void SetupAppearance()
        {
            FeedTable.BackgroundColor = Appearance.Colors.BackgroundColor;

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                FeedTable.AtTopOf(View),
                FeedTable.AtLeftOf(View),
                FeedTable.AtRightOf(View),
                FeedTable.AtBottomOf(View)
                );
        }
Exemplo n.º 27
0
        /// <summary>
        /// Delete featured topic
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="topicHandle">Topic handle</param>
        /// <returns>Delete featured topic task</returns>
        public async Task DeleteFeaturedTopic(
            StorageConsistencyMode storageConsistencyMode,
            string appHandle,
            string topicHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.FeaturedTopics);

            FeedTable   table       = this.tableStoreManager.GetTable(ContainerIdentifier.FeaturedTopics, TableIdentifier.FeaturedTopicsFeed) as FeedTable;
            Transaction transaction = new Transaction();

            transaction.Add(Operation.Delete(table, ContainerIdentifier.FeaturedTopics.ToString(), appHandle, topicHandle));
            transaction.Add(Operation.Delete(table, ContainerIdentifier.FeaturedTopics.ToString(), MasterApp.AppHandle, topicHandle));
            await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 28
0
        /// <summary>
        /// Insert user
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="identityProviderType">Identity provider type</param>
        /// <param name="accountId">Account id</param>
        /// <param name="appHandle">App handle</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="bio">User bio</param>
        /// <param name="photoHandle">Photo handle</param>
        /// <param name="visibility">User visibility</param>
        /// <param name="createdTime">Created time</param>
        /// <param name="requestId">Request Id</param>
        /// <returns>Insert user task</returns>
        public async Task InsertUser(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            IdentityProviderType identityProviderType,
            string accountId,
            string appHandle,
            string firstName,
            string lastName,
            string bio,
            string photoHandle,
            UserVisibilityStatus visibility,
            DateTime createdTime,
            string requestId)
        {
            UserProfileEntity userProfileEntity = new UserProfileEntity()
            {
                FirstName       = firstName,
                LastName        = lastName,
                Bio             = bio,
                CreatedTime     = createdTime,
                LastUpdatedTime = createdTime,
                Visibility      = visibility,
                PhotoHandle     = photoHandle,
                ReviewStatus    = ReviewStatus.Active,
                RequestId       = requestId
            };

            AppFeedEntity appFeedEntity = new AppFeedEntity()
            {
                AppHandle = appHandle
            };

            LinkedAccountFeedEntity linkedAccountFeedEntity = new LinkedAccountFeedEntity()
            {
                IdentityProviderType = identityProviderType,
                AccountId            = accountId
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users);

            ObjectTable profilesTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserProfilesObject) as ObjectTable;
            FeedTable   appsTable     = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserAppsFeed) as FeedTable;
            FeedTable   accountsTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserLinkedAccountsFeed) as FeedTable;
            Transaction transaction   = new Transaction();

            transaction.Add(Operation.Insert(profilesTable, userHandle, appHandle, userProfileEntity));
            transaction.Add(Operation.Insert(appsTable, userHandle, this.tableStoreManager.DefaultFeedKey, appHandle, appFeedEntity));
            transaction.Add(Operation.Insert(accountsTable, userHandle, this.tableStoreManager.DefaultFeedKey, identityProviderType.ToString(), linkedAccountFeedEntity));
            await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 29
0
        /// <summary>
        /// Delete user
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <returns>Delete user task</returns>
        public async Task DeleteUserProfile(
            StorageConsistencyMode storageConsistencyMode,
            string userHandle,
            string appHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users);

            ObjectTable profilesTable = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserProfilesObject) as ObjectTable;
            FeedTable   appsTable     = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserAppsFeed) as FeedTable;
            Transaction transaction   = new Transaction();

            transaction.Add(Operation.Delete(profilesTable, userHandle, appHandle));
            transaction.Add(Operation.Delete(appsTable, userHandle, this.tableStoreManager.DefaultFeedKey, appHandle));
            await store.ExecuteTransactionAsync(transaction, storageConsistencyMode.ToConsistencyMode());
        }
Exemplo n.º 30
0
        /// <summary>
        /// Insert developer app
        /// </summary>
        /// <param name="storageConsistencyMode">Storage consistency mode</param>
        /// <param name="developerId">Developer id</param>
        /// <param name="appHandle">App handle</param>
        /// <returns>Insert developer app task</returns>
        public async Task InsertDeveloperApp(
            StorageConsistencyMode storageConsistencyMode,
            string developerId,
            string appHandle)
        {
            AppFeedEntity appFeedEntity = new AppFeedEntity()
            {
                AppHandle = appHandle
            };

            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.DeveloperApps);

            FeedTable table     = this.tableStoreManager.GetTable(ContainerIdentifier.DeveloperApps, TableIdentifier.DeveloperAppsFeed) as FeedTable;
            Operation operation = Operation.Insert(table, developerId, this.tableStoreManager.DefaultFeedKey, appHandle, appFeedEntity);
            await store.ExecuteOperationAsync(operation, storageConsistencyMode.ToConsistencyMode());
        }