bugs in MembershipService.cs and ModerationMessageAlteration.cs?

Oct 21, 2010 at 11:27 AM

in MembershipService.cs

public IUser CreateUser(CreateUserParams createUserParams) {
....
            if ( registrationSettings != null  && registrationSettings.UsersAreModerated && registrationSettings.NotifyModeration && !createUserParams.IsApproved ) {
                var superUser = GetUser(CurrentSite.SuperUser);
                if(superUser != null)
                    _messageManager.Send(superUser.ContentItem.Record, MessageTypes.Moderation);
            }

            return user;
        }

should be the following:

public IUser CreateUser(CreateUserParams createUserParams) {
....
            if ( registrationSettings != null  && registrationSettings.UsersAreModerated && registrationSettings.NotifyModeration && !createUserParams.IsApproved ) {
                var superUser = GetUser(CurrentSite.SuperUser);
                if(superUser != null)
                    _messageManager.Send(superUser.ContentItem.Record, MessageTypes.Moderation, "Email", new Dictionary<string, string> { { "UserName", user.UserName } });
            }

            return user;
}

in ModerationMessageAlteration.cs

public void Sending(MessageContext context) {
            var contentItem = _contentManager.Get(context.Recipient.Id);
            if ( contentItem == null )
                return;

            var recipient = contentItem.As<UserPart>();
            if ( recipient == null )
                return;

            if ( context.Type == MessageTypes.Moderation ) {
                context.MailMessage.Subject = "User needs moderation";
                context.MailMessage.Body = string.Format("The following user account needs to be moderated: {0}", recipient.UserName);

            }

            if ( context.Type == MessageTypes.Validation ) {
                context.MailMessage.Subject = "User account validation";
                context.MailMessage.Body = string.Format("Dear {0}, please <a href=\"{1}\">click here</a> to validate you email address.", recipient.UserName, context.Properties["ChallengeUrl"]);
            }

}

should be the following:

public void Sending(MessageContext context) {
            var contentItem = _contentManager.Get(context.Recipient.Id);
            if ( contentItem == null )
                return;

            var recipient = contentItem.As<UserPart>();
            if ( recipient == null )
                return;

            if ( context.Type == MessageTypes.Moderation ) {
                context.MailMessage.Subject = "User needs moderation";
                context.MailMessage.Body = string.Format("The following user account needs to be moderated: {0}", context.Properties["UserName"]);
            }

            if ( context.Type == MessageTypes.Validation ) {
                context.MailMessage.Subject = "User account validation";
                context.MailMessage.Body = string.Format("Dear {0}, please <a href=\"{1}\">click here</a> to validate you email address.", recipient.UserName, context.Properties["ChallengeUrl"]);
            }

}

Coordinator
Oct 21, 2010 at 3:29 PM

This works also, but why are you suggesting this change ? Can't we fairly assume that we only want to target users with those messages ?

Oct 22, 2010 at 2:13 AM
Edited Oct 22, 2010 at 2:15 AM

I mean, when a new user is created, which should notify the SuperUser of new users need to be moderated. so the message is:

recipient : SuperUser;

body: "The following user account needs to be moderated: newUserName".