コード例 #1
0
        private static void Block(BigDB bigDb, string userId, string blockId, bool block, string blockProp,
                                  Callback callback)
        {
            bigDb.LoadOrCreate(BlockingTable, userId, blockingTable =>
            {
                var blockingObject = blockingTable.GetObject(blockProp);

                if (blockingObject == null)
                {
                    blockingObject = new DatabaseObject();
                    blockingTable.Set(blockProp, blockingObject);
                }

                if (block)
                {
                    blockingObject.Set(blockId, true);
                }
                else
                {
                    blockingObject.Remove(blockId);
                }

                blockingTable.Save();
                callback();
            });
        }
コード例 #2
0
        public static void DismissNotification(BigDB bigDb, string connectUserId, string notificationId,
                                               EENotification[] ignoreList)
        {
            var ignoreIds = ignoreList.Select(i => i.Key).ToArray();

            bigDb.LoadOrCreate("Dismisses", connectUserId, obj =>
            {
                if (!obj.Contains("Notifications"))
                {
                    obj.Set("Notifications", new DatabaseArray());
                }

                var notifications = obj.GetArray("Notifications");
                notifications.Add(notificationId);

                // remove all unused notifications
                for (var i = 0; i < notifications.Count; i++)
                {
                    if (!ignoreIds.Contains(notifications[0]))
                    {
                        notifications.RemoveAt(i);
                    }
                }

                obj.Save();
            });
        }
コード例 #3
0
 public static void BlockAll(BigDB bigDb, string userId, bool block, string blockProp)
 {
     bigDb.LoadOrCreate(BlockingTable, userId, blockingTable =>
     {
         blockingTable.Set(blockProp, block);
         blockingTable.Save();
     });
 }
コード例 #4
0
        public static void AddSubscription(BigDB bigDb, string connectUserId, string channel,
                                           Callback <bool> callback = null)
        {
            bigDb.LoadOrCreate("Subscriptions", connectUserId, obj =>
            {
                if (!obj.GetBool(channel, false))
                {
                    obj.Set(channel, true);
                    obj.Save();

                    if (callback != null)
                    {
                        callback.Invoke(true);
                    }
                }
                else
                {
                    if (callback != null)
                    {
                        callback.Invoke(false);
                    }
                }
            });
        }