r7293 - in dumbhippo/trunk/server: src/com/dumbhippo/persistence src/com/dumbhippo/server src/com/dumbhippo/server/impl web/jsp-gnome web/tags/2



Author: marinaz
Date: 2008-02-06 19:35:04 -0600 (Wed, 06 Feb 2008)
New Revision: 7293

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/persistence/AccountType.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/CreateInvitationResult.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/InvitationSystem.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PostingBoardBean.java
   dumbhippo/trunk/server/web/jsp-gnome/who-are-you.jsp
   dumbhippo/trunk/server/web/tags/2/selfInvite.tag
Log:
Improve the message that we show if someone is trying to sign up for 
Mugshot/GNOME Online with an e-mail that is registered with an account. 
Pre-fill the log in e-mail field with the attempted value in the GNOME
Online case.

Send e-mail invitations to use Mugshot with a login link in them to 
GNOME Online users who did not enable Mugshot and to people who disabled
their account or did not accept terms of use.  

Modified: dumbhippo/trunk/server/src/com/dumbhippo/persistence/AccountType.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/persistence/AccountType.java	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/src/com/dumbhippo/persistence/AccountType.java	2008-02-07 01:35:04 UTC (rev 7293)
@@ -1,6 +1,16 @@
 package com.dumbhippo.persistence;
 
 public enum AccountType {
-    GNOME,
-    MUGSHOT
+    GNOME("GNOME Online"),
+    MUGSHOT("Mugshot");
+    
+    private String name;
+	
+	private AccountType(String name) {
+		this.name = name;
+	}
+	
+	public String getName() {
+		return name;
+	}
 }

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/CreateInvitationResult.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/CreateInvitationResult.java	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/CreateInvitationResult.java	2008-02-07 01:35:04 UTC (rev 7293)
@@ -12,4 +12,5 @@
 	NEW_INVITER,
 	REPEAT_INVITE,
 	ALREADY_HAS_ACCOUNT,
+	ALREADY_HAS_INACTIVE_ACCOUNT
 }

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/InvitationSystem.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/InvitationSystem.java	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/InvitationSystem.java	2008-02-07 01:35:04 UTC (rev 7293)
@@ -11,6 +11,7 @@
 import com.dumbhippo.persistence.EmailResource;
 import com.dumbhippo.persistence.InvitationToken;
 import com.dumbhippo.persistence.Resource;
+import com.dumbhippo.persistence.Token;
 import com.dumbhippo.persistence.User;
 import com.dumbhippo.persistence.ValidationException;
 import com.dumbhippo.server.views.InvitationView;
@@ -119,7 +120,10 @@
 	/**
 	 * Ensure the invitation from inviter to invitee exists, if it makes sense. 
 	 * Returns the current status of that invitation, and the created invitation token 
-	 * if any (this will be null if none was created or exists).
+	 * if any (this will be null if none was created or exists). Returns the current status
+	 * of the account, and a login token for the invitee if there account is not public
+	 * or disabled.
+	 * 
 	 * Does not send out any invitation emails or anything.
 	 * 
 	 * Use this for "implicit invitation" when sharing something with someone.
@@ -132,7 +136,7 @@
 	 * @param message message to send (from the inviter to invitee), text format
 	 * @return the outcome
 	 */
-	public Pair<CreateInvitationResult,InvitationToken> 
+	public Pair<CreateInvitationResult, Token> 
 	    createInvitation(User inviter, PromotionCode promotionCode, Resource invitee,
 			             String subject, String message);
 	

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/InvitationSystemBean.java	2008-02-07 01:35:04 UTC (rev 7293)
@@ -26,12 +26,15 @@
 import com.dumbhippo.XmlBuilder;
 import com.dumbhippo.email.MessageContent;
 import com.dumbhippo.persistence.Account;
+import com.dumbhippo.persistence.AccountType;
 import com.dumbhippo.persistence.Client;
 import com.dumbhippo.persistence.EmailResource;
 import com.dumbhippo.persistence.Group;
 import com.dumbhippo.persistence.InvitationToken;
 import com.dumbhippo.persistence.InviterData;
+import com.dumbhippo.persistence.LoginToken;
 import com.dumbhippo.persistence.Resource;
+import com.dumbhippo.persistence.Token;
 import com.dumbhippo.persistence.User;
 import com.dumbhippo.persistence.ValidationException;
 import com.dumbhippo.server.AccountSystem;
@@ -40,9 +43,11 @@
 import com.dumbhippo.server.CreateInvitationResult;
 import com.dumbhippo.server.GroupSystem;
 import com.dumbhippo.server.HippoProperty;
+import com.dumbhippo.server.HumanVisibleException;
 import com.dumbhippo.server.IdentitySpider;
 import com.dumbhippo.server.InvitationSystem;
 import com.dumbhippo.server.InvitationSystemRemote;
+import com.dumbhippo.server.LoginVerifier;
 import com.dumbhippo.server.Mailer;
 import com.dumbhippo.server.NoMailSystem;
 import com.dumbhippo.server.NotFoundException;
@@ -92,6 +97,9 @@
 	
 	@EJB
 	private IdentitySpider identitySpider;
+	
+	@EJB
+	private LoginVerifier loginVerifier;
 
 	private InvitationToken lookupInvitationFor(Resource invitee) {
 		List<InvitationToken> invites = lookupInvitationsFor(invitee, true);
@@ -419,7 +427,7 @@
 		return iv;
 	}
 	
-	public Pair<CreateInvitationResult,InvitationToken> 
+	public Pair<CreateInvitationResult,Token> 
 	    createInvitation(User inviter, PromotionCode promotionCode, Resource invitee, 
 	    		         String subject, String message) {
 		// be sure the invitee is our contact (even if we 
@@ -429,8 +437,19 @@
 		// sending mail to disabled accounts 
 		User user = spider.lookupUserByResource(SystemViewpoint.getInstance(), invitee);
 		if (user != null) {
-			logger.debug("not inviting '{}' due to existing user {}", invitee, user);
-			return new Pair<CreateInvitationResult,InvitationToken>(CreateInvitationResult.ALREADY_HAS_ACCOUNT, null);
+			if (user.getAccount().isActive() && user.getAccount().isPublicPage()) {
+			    logger.debug("not inviting '{}' due to existing user {}", invitee, user);
+			    return new Pair<CreateInvitationResult,Token>(CreateInvitationResult.ALREADY_HAS_ACCOUNT, null);
+			} else {
+			    logger.debug("not inviting '{}' due to existing user {}, but sending them a login link since their account is disabled", invitee, user);
+			    try {
+			        return new Pair<CreateInvitationResult,Token>(CreateInvitationResult.ALREADY_HAS_INACTIVE_ACCOUNT, loginVerifier.getLoginToken(invitee));				
+			    } catch (HumanVisibleException e) {
+			    	throw new RuntimeException("could not create a login link for " + invitee, e);			    					
+			    } catch (RetryException e) {
+			    	throw new RuntimeException("could not create a login link for " + invitee, e);			    							    	
+			    }
+			}
 		}
 
 		CreateInvitationResult result = CreateInvitationResult.REPEAT_INVITE;
@@ -442,7 +461,7 @@
 				account.deductInvitations(1);
 			} else {
 				result = CreateInvitationResult.INVITE_WAS_NOT_CREATED;
-				return new Pair<CreateInvitationResult,InvitationToken>(result, null);
+				return new Pair<CreateInvitationResult,Token>(result, null);
 			}
 			
 			// renewing an expiration counts as creating (causes us to send new email)
@@ -481,7 +500,7 @@
 			if (promotionCode != null && iv.getPromotion() == null)
 				iv.setPromotionCode(promotionCode);
 		}
-	    return new Pair<CreateInvitationResult,InvitationToken>(result, iv);
+	    return new Pair<CreateInvitationResult,Token>(result, iv);
 	}
 	
 	/**
@@ -556,15 +575,19 @@
 	private String sendInvitation(final UserViewpoint viewpoint, final PromotionCode promotionCode, 
 			                      final Resource invitee, final String subject, final String message) {
 		User inviter = viewpoint.getViewer();
-		Pair<CreateInvitationResult,InvitationToken> p = createInvitation(inviter, promotionCode, invitee, subject, message);
+		Pair<CreateInvitationResult,Token> p = createInvitation(inviter, promotionCode, invitee, subject, message);
 		CreateInvitationResult result = p.getFirst();
-		final InvitationToken iv = p.getSecond();
+		final Token token = p.getSecond();
 		String note = null;
+		User user = null;
+		
 		if (result == CreateInvitationResult.INVITE_WAS_NOT_CREATED) {
 			return "Your invitation was not sent because you are out of invitation vouchers."; 
 		} else if (result == CreateInvitationResult.ALREADY_HAS_ACCOUNT) {
-			User user = spider.lookupUserByResource(viewpoint, invitee);
+			user = spider.lookupUserByResource(viewpoint, invitee);
 			String hasAccount = invitee.getHumanReadableString() + " already has an account '" + user.getNickname() + "'";
+			if (accounts.isSpecialCharacter(inviter) && viewpoint.getSite().getAccountType() != user.getAccount().getAccountType())
+				hasAccount= hasAccount + ". This " + user.getAccount().getAccountType().getName() + " account can be used to log in to " + viewpoint.getSite().getSiteName();
 			
 			// special character invites you on the /signup page if you have no account
 			if (!accounts.isSpecialCharacter(inviter))
@@ -575,9 +598,11 @@
 			// note should be null or contain INVITATION_SUCCESS_STRING to indicate a successful invitation
 			if (result == CreateInvitationResult.REPEAT_INVITE) {
 				note = INVITATION_SUCCESS_STRING + ", another invitation was sent to " + invitee.getHumanReadableString() + ".";				
-			} else if (result == CreateInvitationResult.NEW_INVITER) {
+			} else if (result == CreateInvitationResult.NEW_INVITER || result == CreateInvitationResult.ALREADY_HAS_INACTIVE_ACCOUNT) {
 				note = INVITATION_SUCCESS_STRING + ", an invitation was sent to " + invitee.getHumanReadableString() + "."
-				       + " You didn't have to spend an invitation because they were already invited by someone else."; 			
+				       + " You didn't have to spend an invitation because they were already invited by someone else."; 		
+				if (result == CreateInvitationResult.ALREADY_HAS_INACTIVE_ACCOUNT)
+				    user = spider.lookupUserByResource(viewpoint, invitee);
 			} else if (result == CreateInvitationResult.INVITE_CREATED) {
 				note = INVITATION_SUCCESS_STRING + ", an invitation was sent to " + invitee.getHumanReadableString() + ".";
 			} else {
@@ -587,7 +612,7 @@
 			
 			// In all the three of the above cases, we want to send a notification		
 			if (invitee instanceof EmailResource) {
-				sendEmailNotification(viewpoint, iv, subject, message);			
+				sendEmailNotification(viewpoint, token, user, subject, message);			
 			} else {
 				throw new RuntimeException("no way to send this invite! unhandled resource type " + invitee.getClass().getName());
 			}
@@ -784,14 +809,16 @@
 	static private class InviteMessageContent extends MessageContent {
 
 		private Site site;
+		private User user;
 		private String subject;
 		private String message;
 		private String inviteUrl;
 		private String inviterName;
 		private String inviterPageUrl;
 		
-		InviteMessageContent(Site site, String subject, String message, String inviteUrl, String inviterName, String inviterPageUrl) {
+		InviteMessageContent(Site site, User user, String subject, String message, String inviteUrl, String inviterName, String inviterPageUrl) {
 			this.site = site;
+			this.user = user;
 			this.subject = subject;
 			this.message = message != null ? message.trim() : "";
 			this.inviteUrl = inviteUrl;
@@ -823,7 +850,29 @@
 				appendBlockquote(messageText, messageHtml, message);
 			}
 			
-			appendParagraph(messageText, messageHtml, "Follow this link to get started:");
+			if (user != null && (user.getAccount().isDisabled() || user.getAccount().isAdminDisabled())) {
+				if (user.getAccount().getAccountType() == AccountType.GNOME)
+			        appendParagraph(messageText, messageHtml, "Your online.gnome.org account is currently disabled and is not visible publicly." +
+			    		                                      " Follow this link if you want to reenable it and start using Mugshot: ");
+				else 
+					appendParagraph(messageText, messageHtml, "Your Mugshot account is currently disabled and is not visible publicly." +
+                                                              " Follow this link if you want to reenable it: ");				
+			} else if (user != null && (!user.getAccount().getHasAcceptedTerms())) {
+				if (user.getAccount().getAccountType() == AccountType.GNOME)
+			        appendParagraph(messageText, messageHtml, "Your online.gnome.org account is currently disabled and is not visible publicly because you did not accept terms of use." +
+                                                              " Follow this link if you want to enable it and start using Mugshot: ");	
+				else 
+			        appendParagraph(messageText, messageHtml, "Your Mugshot account is currently disabled and is not visible publicly because you did not accept terms of use." +
+                                                              " Follow this link if you want to enable it: ");						
+			} else if (user != null && (!user.getAccount().isPublicPage() && user.getAccount().getAccountType() == AccountType.GNOME)) {
+				  appendParagraph(messageText, messageHtml, "You can log in to Mugshot using your online.gnome.org account." +
+                                                            " Follow this link to enable your Mugshot account: ");
+			} else if (user != null) {
+				logger.warn("Sending an e-mail to an invitee who is a Mugshot user {} in an unexpected situation.", user);
+				appendParagraph(messageText, messageHtml, "Follow this link to log in to your Mugshot account:");
+			} else {
+			    appendParagraph(messageText, messageHtml, "Follow this link to get started:");
+			}
 			
 			appendLinkAsBlock(messageText, messageHtml, null, inviteUrl);
 			
@@ -840,10 +889,38 @@
 		}
 	}
 	
-	private void sendEmailNotification(UserViewpoint viewpoint, InvitationToken invite, String subject, String message) {
-		User inviter = viewpoint.getViewer();
-		EmailResource invitee = (EmailResource) invite.getInvitee();
+	private void sendEmailNotification(UserViewpoint viewpoint, Token invite, User user, String subject, String message) {
+		User inviter = viewpoint.getViewer();	
+		EmailResource invitee;
+		String inviteUrl;
 		
+		String baseurl;
+		URL baseurlObject;
+		try {
+			baseurl = configuration.getBaseUrl(viewpoint);
+			baseurlObject = new URL(baseurl);
+		} catch (MalformedURLException e) {
+			throw new RuntimeException(e);
+		}
+		
+		if (invite instanceof InvitationToken) {
+	        invitee = (EmailResource)((InvitationToken)invite).getInvitee();
+		    inviteUrl = invite.getAuthURL(baseurlObject);
+		} else if (invite instanceof LoginToken) {
+			invitee = (EmailResource)((LoginToken)invite).getResource();
+			if (user.getAccount().getAccountType() == AccountType.GNOME && !user.getAccount().isActive()) {
+				// If invitee's account is not active (i.e. if it is disabled or they have not accepted terms of use,
+				// we need to send them to the GNOME Online site first. They can then enable Mugshot from there. 
+			    inviteUrl = invite.getAuthURL(configuration.getBaseUrlGnome()) + "&next=account";
+			} else {
+				// If a GNOME Online user never enabled Mugshot (publicPage == false), we can send them directly to
+				// the Mugshot site. We send people to the Mugshot site in all other cases too.
+				inviteUrl = invite.getAuthURL(configuration.getBaseUrlMugshot()) + "&next=account";
+			}
+		} else {
+			throw new RuntimeException("Unexpected subclass of Token in sendEmailNotification " + invite.getClass());
+		}
+		
 		if (!noMail.getMailEnabled(invitee)) {
 			logger.debug("Mail is disabled to {} not sending invitation", invitee);
 			return;
@@ -858,15 +935,6 @@
 		PersonView viewedInviter = personViewer.getPersonView(viewpoint, inviter);
 		String inviterName = viewedInviter.getName();
 		
-		String baseurl;
-		URL baseurlObject;
-		try {
-			baseurl = configuration.getBaseUrl(viewpoint);
-			baseurlObject = new URL(baseurl);
-		} catch (MalformedURLException e) {
-			throw new RuntimeException(e);
-		}
-		
 		User mugshot = accounts.getSiteCharacter(viewpoint.getSite());
 		boolean isMugshotInvite = (viewedInviter.getUser().equals(mugshot));
 		
@@ -876,12 +944,12 @@
 			else
 				subject = "Invitation from " + inviterName + " to join " + viewpoint.getSite().getSiteName();				
 		}
-				
-		String inviteUrl = invite.getAuthURL(baseurlObject);
+						
 		// Only set the inviter for non-mugshot invitations; the download
 		// page assumes the absence of this parameter implies the invitation
 		// was from mugshot, which we handle specially.
 		if (!isMugshotInvite) {
+			// this parameter is not used when it is a pasrt of the login link, but we might as well keep it
 			inviteUrl += "&inviter=";
 			inviteUrl += inviter.getId();
 		}
@@ -891,7 +959,7 @@
 			inviterPageUrl = baseurl + viewedInviter.getHomeUrl();
 		
 		mailer.setMessageContent(msg, viewpoint.getSite(),
-				new InviteMessageContent(viewpoint.getSite(), subject, message, inviteUrl,
+				new InviteMessageContent(viewpoint.getSite(), user, subject, message, inviteUrl,
 						isMugshotInvite ? null : inviterName,
 						inviterPageUrl));
 		

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PostingBoardBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PostingBoardBean.java	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PostingBoardBean.java	2008-02-07 01:35:04 UTC (rev 7293)
@@ -41,12 +41,12 @@
 import com.dumbhippo.persistence.GroupFeed;
 import com.dumbhippo.persistence.GroupMember;
 import com.dumbhippo.persistence.GuidPersistable;
-import com.dumbhippo.persistence.InvitationToken;
 import com.dumbhippo.persistence.MembershipStatus;
 import com.dumbhippo.persistence.Person;
 import com.dumbhippo.persistence.Post;
 import com.dumbhippo.persistence.PostVisibility;
 import com.dumbhippo.persistence.Resource;
+import com.dumbhippo.persistence.Token;
 import com.dumbhippo.persistence.User;
 import com.dumbhippo.persistence.UserBlockData;
 import com.dumbhippo.postinfo.NodeName;
@@ -292,7 +292,7 @@
 					// or already has an account (it's also very cheap if bestResource is an Account)
 					// this does not send out an e-mail to invitee, but prepares an invite
 					// to be sent out with the post, if applicable
-					Pair<CreateInvitationResult,InvitationToken> result = invitationSystem.createInvitation(poster, null, bestResource, "", "");
+					Pair<CreateInvitationResult,Token> result = invitationSystem.createInvitation(poster, null, bestResource, "", "");
 					if (result.getFirst() == CreateInvitationResult.INVITE_WAS_NOT_CREATED && inviteRecipients == InviteRecipients.MUST_INVITE) {
 						// It probably would be better to throw an exception and propagate that
 						// back into a nice message to the user, but just avoiding sending the

Modified: dumbhippo/trunk/server/web/jsp-gnome/who-are-you.jsp
===================================================================
--- dumbhippo/trunk/server/web/jsp-gnome/who-are-you.jsp	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/web/jsp-gnome/who-are-you.jsp	2008-02-07 01:35:04 UTC (rev 7293)
@@ -42,10 +42,6 @@
 			</form>
 			
 			<div>
-				<c:if test="${!empty whoareyou.aimBotScreenName}">
-					<%-- c:if on one line here to avoid weird link text spacing --%>
-					<a href="aim:GoIM?screenname=${whoareyou.aimBotScreenName}&message=Hey+Bot!+Send+me+a+login+link!"><c:if test="${!empty whoareyou.aimPresenceKey}"><img src="http://api.oscar.aol.com/SOA/key=${whoareyou.aimPresenceKey}/presence/${whoareyou.aimBotScreenName}"; border="0"/> </c:if>AIM log in</a> |
-				</c:if>
 				<a id="dhLoginTogglePasswordLink" href="javascript:dh.login.togglePasswordBox()"><%-- filled in by javascript --%></a>&nbsp; [alt-p]
 			</div>
 		</div>
@@ -59,7 +55,7 @@
 		                <dht2:selfInvite promotion="${landing.openSignupPromotion}" invitesAvailable="${landing.selfInvitations}"/>
 				    </c:when>
 				    <c:otherwise>
-			            <p><strong>Enter your email address and we'll let you know when GNOME Online has more room.
+			            <p><strong>Enter your email address and we'll let you know when GNOME Online has more room. If you have a Mugshot account you can use it to log in.
 			            </strong></p>
 		                <dht2:wantsIn buttonText="Sign Me Up!"/>
 		            </c:otherwise>

Modified: dumbhippo/trunk/server/web/tags/2/selfInvite.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/2/selfInvite.tag	2008-02-06 23:46:36 UTC (rev 7292)
+++ dumbhippo/trunk/server/web/tags/2/selfInvite.tag	2008-02-07 01:35:04 UTC (rev 7293)
@@ -59,6 +59,10 @@
 							text = "Something went wrong... (2)";
 						else
 							text = messageElement ? dojo.dom.textContent(messageElement) : "Something went wrong... (3)";
+							if (text.indexOf(" already has an account") > 0 && dh.util.exists('dhLoginAddressEntry')) {
+							    email = text.substring(0, text.indexOf(" already has an account"));
+							    document.getElementById('dhLoginAddressEntry').value = email;    
+							}
 					}
 					dhSelfInviteComplete${N}(text);
 	  	    	 },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]