示例#1
0
        private void SendJoinCommunityMail(PermissionItem permission)
        {
            try
            {
                // Send Mail.
                var request = new JoinCommunityRequest();
                request.CommunityID = permission.CommunityID;
                request.CommunityName = permission.CommunityName;
                request.RequestorID = permission.UserID;
                request.RequestorName = permission.Name;
                request.PermissionRequested = permission.Role.ToString();
                request.RequestorLink = string.Format(CultureInfo.InvariantCulture, "{0}Profile/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.UserID);
                request.CommunityLink = string.Format(CultureInfo.InvariantCulture, "{0}Community/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.CommunityID);

                _notificationService.NotifyJoinCommunity(request);
            }
            catch (Exception)
            {
                // Ignore all exceptions.
            }
        }
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, JoinCommunityRequest request)
        {
            if (thisObject == null)
            {
                thisObject = new EmailRequest();
            }

            ICommunityRepository communityRepository = DependencyResolver.Current.GetService(typeof(ICommunityRepository)) as ICommunityRepository;
            IEnumerable<User> approvers = communityRepository.GetApprovers(request.CommunityID);

            foreach (User user in approvers)
            {
                if (user.IsSubscribed)
                {
                    thisObject.Recipients.Add(new MailAddress(user.Email.FixEmailAddress(), user.FirstName + " " + user.LastName));
                }
            }

            string entityName = request.CommunityName;
            bool isFolder = false;
            Community community = communityRepository.GetItem(c => c.CommunityID == request.CommunityID);
            if (community != null)
            {
                entityName = community.Name;
                isFolder = community.CommunityTypeID == (int)CommunityTypes.Folder;
            }

            IUserRepository userRepository = DependencyResolver.Current.GetService(typeof(IUserRepository)) as IUserRepository;
            User requestor = userRepository.GetItem(u => u.UserID == request.RequestorID);

            thisObject.IsHtml = true;

            // Update the body and the subject.
            thisObject.Subject = string.Format(CultureInfo.CurrentUICulture, "{0} has requested to join your Layerscape {1}: \"{2}\"", requestor.GetFullName(), isFolder ? "folder" : "community", entityName);

            var replacements = new Dictionary<string, string>
            {
                { "@@[email protected]@", string.Empty }, 
                { "@@[email protected]@", HttpUtility.UrlDecode(entityName) }, 
                { "@@[email protected]@", HttpUtility.UrlDecode(request.CommunityLink) },
                { "@@[email protected]@", HttpUtility.UrlDecode(requestor.GetFullName()) },
                { "@@[email protected]@", HttpUtility.UrlDecode(request.RequestorID.ToString()) },
                { "@@[email protected]@", HttpUtility.UrlDecode(request.RequestorLink) },
                { "@@[email protected]@", isFolder ? "folder" : "community" },
                { "@@[email protected]@", HttpUtility.UrlDecode(request.PermissionRequested) },
            };
            thisObject.MessageBody = FormatMailBodyUsingTemplate("joincommunityrequest.html", replacements);

            return thisObject;
        }
示例#3
0
 /// <summary>
 /// Notify the moderators and owners about the an offensive community/content.
 /// </summary>
 /// <param name="notification">Offensive entity details</param>
 public void NotifyJoinCommunity(JoinCommunityRequest notification)
 {
     SendMail(notification);
 }