示例#1
0
        /// <summary>
        /// 检查用户是否接收动态
        /// </summary>
        /// <param name="userId">UserId</param>
        /// <param name="activityItemKey">动态项目标识</param>
        /// <param name="fromOwnerId">动态拥有者</param>
        /// <returns>接收动态返回true,否则返回false</returns>
        private bool IsReceiveActivity(ActivityService activityService, long userId, Activity activity)
        {
            //首先检查是否屏蔽用户
            UserBlockService userBlockService = new UserBlockService();

            if (userBlockService.IsBlockedUser(userId, activity.OwnerId))
            {
                return(false);
            }

            //检查用户是否接收该动态项目
            Dictionary <string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);

            if (userSettings.ContainsKey(activity.ActivityItemKey))
            {
                return(userSettings[activity.ActivityItemKey]);
            }
            else
            {
                //如果用户没有设置从默认设置获取
                ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
                if (activityItem != null)
                {
                    return(activityItem.IsUserReceived);
                }
                else
                {
                    return(true);
                }
            }
        }
示例#2
0
 /// <summary>
 /// 检查用户是否接收动态
 /// </summary>
 /// <param name="activityService"></param>
 /// <param name="isPublic">群组是否为公开群组</param>
 /// <param name="userId">UserId</param>
 /// <param name="activity">动态</param>
 /// <returns>接收动态返回true,否则返回false</returns>
 private bool IsReceiveActivity(ActivityService activityService, bool isPublic, long userId, Activity activity)
 {
     if (isPublic)
     {
         //检查用户是否已在信息发布者的粉丝圈里面
         FollowService followService = new FollowService();
         if (followService.IsFollowed(userId, activity.UserId))
             return false;
     }
     //检查用户是否已屏蔽群组
     if (new UserBlockService().IsBlockedGroup(userId, activity.OwnerId))
         return false;
     //检查用户是否接收该动态项目
     Dictionary<string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);
     if (userSettings.ContainsKey(activity.ActivityItemKey))
         return userSettings[activity.ActivityItemKey];
     else
     {
         //如果用户没有设置从默认设置获取
         ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
         if (activityItem != null)
             return activityItem.IsUserReceived;
         else
             return true;
     }
 }
        /// <summary>
        /// 检查用户是否接收动态
        /// </summary>
        /// <param name="userId">UserId</param>
        /// <param name="activityItemKey">动态项目标识</param>
        /// <param name="fromOwnerId">动态拥有者</param>
        /// <returns>接收动态返回true,否则返回false</returns>
        private bool IsReceiveActivity(ActivityService activityService, long userId, Activity activity)
        {
            //首先检查是否屏蔽用户
            UserBlockService userBlockService = new UserBlockService();

            if (userBlockService.IsBlockedUser(userId, activity.OwnerId))
            {
                return(false);
            }

            //被验证用户为黑名单用户
            PrivacyService privacyService = new PrivacyService();

            if (privacyService.IsStopedUser(activity.OwnerId, userId))
            {
                return(false);
            }

            //判断指定对象可见
            Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > dictionary = new ContentPrivacyService().GetPrivacySpecifyObjects(activity.TenantTypeId, activity.SourceId);

            if (dictionary != null && dictionary.Count() > 0)
            {
                foreach (var pair in dictionary)
                {
                    IPrivacySpecifyObjectValidator privacySpecifyUserGetter = DIContainer.ResolveNamed <IPrivacySpecifyObjectValidator>(pair.Key.ToString());
                    foreach (var specifyObject in pair.Value)
                    {
                        if (privacySpecifyUserGetter.Validate(activity.OwnerId, userId, specifyObject.SpecifyObjectId))
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }

            //检查用户是否接收该动态项目
            Dictionary <string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);

            if (userSettings.ContainsKey(activity.ActivityItemKey))
            {
                return(userSettings[activity.ActivityItemKey]);
            }
            else
            {
                //如果用户没有设置从默认设置获取
                ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
                if (activityItem != null)
                {
                    return(activityItem.IsUserReceived);
                }
                else
                {
                    return(true);
                }
            }
        }
        /// <summary>
        /// 检查用户是否接收动态
        /// </summary>
        /// <param name="userId">UserId</param>
        /// <param name="activityItemKey">动态项目标识</param>
        /// <param name="fromOwnerId">动态拥有者</param>
        /// <returns>接收动态返回true,否则返回false</returns>
        private bool IsReceiveActivity(ActivityService activityService, long userId, Activity activity)
        {
            //首先检查是否屏蔽用户
            UserBlockService userBlockService = new UserBlockService();
            if (userBlockService.IsBlockedUser(userId, activity.OwnerId))
                return false;

            //被验证用户为黑名单用户
            PrivacyService privacyService = new PrivacyService();
            if (privacyService.IsStopedUser(activity.OwnerId, userId))
                return false;

            //判断指定对象可见
            Dictionary<int, IEnumerable<ContentPrivacySpecifyObject>> dictionary = new ContentPrivacyService().GetPrivacySpecifyObjects(activity.TenantTypeId, activity.SourceId);
            if (dictionary != null && dictionary.Count() > 0)
            {
                foreach (var pair in dictionary)
                {
                    IPrivacySpecifyObjectValidator privacySpecifyUserGetter = DIContainer.ResolveNamed<IPrivacySpecifyObjectValidator>(pair.Key.ToString());
                    foreach (var specifyObject in pair.Value)
                    {
                        if (privacySpecifyUserGetter.Validate(activity.OwnerId, userId, specifyObject.SpecifyObjectId))
                            return true;
                    }
                }
                return false;
            }

            //检查用户是否接收该动态项目
            Dictionary<string, bool> userSettings = activityService.GetActivityItemUserSettings(userId);
            if (userSettings.ContainsKey(activity.ActivityItemKey))
                return userSettings[activity.ActivityItemKey];
            else
            {
                //如果用户没有设置从默认设置获取
                ActivityItem activityItem = activityService.GetActivityItem(activity.ActivityItemKey);
                if (activityItem != null)
                    return activityItem.IsUserReceived;
                else
                    return true;
            }
        }