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> { { "@@ApproverName@@", string.Empty }, { "@@CommunityName@@", HttpUtility.UrlDecode(entityName) }, { "@@CommunityLink@@", HttpUtility.UrlDecode(request.CommunityLink) }, { "@@RequestorName@@", HttpUtility.UrlDecode(requestor.GetFullName()) }, { "@@RequestorID@@", HttpUtility.UrlDecode(request.RequestorID.ToString()) }, { "@@RequestorLink@@", HttpUtility.UrlDecode(request.RequestorLink) }, { "@@CommunityType@@", isFolder ? "folder" : "community" }, { "@@PermissionRequested@@", HttpUtility.UrlDecode(request.PermissionRequested) }, }; thisObject.MessageBody = FormatMailBodyUsingTemplate("joincommunityrequest.html", replacements); return(thisObject); }
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, object request) { //// TODO: Need to Get the Email request from the content of the message. //// TODO: Also we need to write a static methods for converting from the input request to the Email Request. if (thisObject == null) { thisObject = new EmailRequest(); } JoinCommunityRequest joinRequest = request as JoinCommunityRequest; if (joinRequest != null) { return(thisObject.UpdateFrom(joinRequest)); } FlaggedRequest flaggedRequest = request as FlaggedRequest; if (flaggedRequest != null) { return(thisObject.UpdateFrom(flaggedRequest)); } EntityCommentRequest entityCommentRequest = request as EntityCommentRequest; if (entityCommentRequest != null) { return(thisObject.UpdateFrom(entityCommentRequest)); } ModeratorPermissionStatusRequest moderatorPermissionStatusRequest = request as ModeratorPermissionStatusRequest; if (moderatorPermissionStatusRequest != null) { return(thisObject.UpdateFrom(moderatorPermissionStatusRequest)); } UserPermissionStatusRequest userPermissionStatusRequest = request as UserPermissionStatusRequest; if (userPermissionStatusRequest != null) { return(thisObject.UpdateFrom(userPermissionStatusRequest)); } RemoveUserRequest removeUserRequest = request as RemoveUserRequest; if (removeUserRequest != null) { return(thisObject.UpdateFrom(removeUserRequest)); } UserPermissionChangedRequest userPermissionChangedRequest = request as UserPermissionChangedRequest; if (userPermissionChangedRequest != null) { return(thisObject.UpdateFrom(userPermissionChangedRequest)); } NotifyInviteRequest notifyInviteRequest = request as NotifyInviteRequest; if (notifyInviteRequest != null) { return(thisObject.UpdateFrom(notifyInviteRequest)); } EntityAdminActionRequest entityAdminDeleteRequest = request as EntityAdminActionRequest; if (entityAdminDeleteRequest != null) { return(thisObject.UpdateFrom(entityAdminDeleteRequest)); } NewEntityRequest newEntityRequest = request as NewEntityRequest; if (newEntityRequest != null) { return(thisObject.UpdateFrom(newEntityRequest)); } return(null); }
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> { { "@@ApproverName@@", string.Empty }, { "@@CommunityName@@", HttpUtility.UrlDecode(entityName) }, { "@@CommunityLink@@", HttpUtility.UrlDecode(request.CommunityLink) }, { "@@RequestorName@@", HttpUtility.UrlDecode(requestor.GetFullName()) }, { "@@RequestorID@@", HttpUtility.UrlDecode(request.RequestorID.ToString()) }, { "@@RequestorLink@@", HttpUtility.UrlDecode(request.RequestorLink) }, { "@@CommunityType@@", isFolder ? "folder" : "community" }, { "@@PermissionRequested@@", HttpUtility.UrlDecode(request.PermissionRequested) }, }; thisObject.MessageBody = FormatMailBodyUsingTemplate("joincommunityrequest.html", replacements); return thisObject; }
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. } }
/// <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); }
/// <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); }