public void SetBuddyInvite(Usr buddyUsr, bool allowBuddyInvite, AddBuddySource source, Buddy.BuddyFindingMethod? foundByMethod, string skeletonName) { if (allowBuddyInvite && !foundByMethod.HasValue) { throw new ArgumentNullException("foundByMethod", "Must have a method when allowBuddyInvite is true"); } ValidateBuddyUsr(buddyUsr); if (this.HasBuddy(buddyUsr.K)) { try { Buddy buddy = new Buddy(this.K, buddyUsr.K); buddy.CanBuddyInvite = allowBuddyInvite; buddy.Update(); #region update reverse buddy try { Buddy reverseBuddy = new Buddy(buddyUsr.K, this.K); reverseBuddy.CanInvite = allowBuddyInvite; reverseBuddy.Update(); } catch (BobNotFound) { } #endregion } catch (Exception ex) { throw ex; } } else if (allowBuddyInvite) { this.AddBuddy(buddyUsr, source, foundByMethod.Value, skeletonName ); } }
public void AddBuddy(Usr buddyUsr, bool canBuddyInvite, bool sendNotificationEmailIfNewBuddyRequest, AddBuddySource source, Buddy.BuddyFindingMethod foundByMethod, string skeletonName) { ValidateBuddyUsr(buddyUsr, true); Buddy b; try { b = new Buddy(this.K, buddyUsr.K); } catch (BobNotFound) { b = new Buddy(); b.UsrK = this.K; b.BuddyUsrK = buddyUsr.K; b.CanBuddyInvite = canBuddyInvite; b.BuddyFoundByMethod = foundByMethod; b.SkeletonName = skeletonName; try { Buddy reverseBuddy = new Buddy(buddyUsr.K, this.K); reverseBuddy.FullBuddy = true; reverseBuddy.Denied = false; reverseBuddy.CanInvite = canBuddyInvite; b.CanInvite = reverseBuddy.CanBuddyInvite; b.FullBuddy = true; b.Denied = false; reverseBuddy.Update(); if (this.FacebookConnected && this.FacebookStoryNewBuddy) { try { FacebookPost.CreateNewBuddy(this, buddyUsr, true); } catch { } } if (buddyUsr.FacebookConnected && buddyUsr.FacebookStoryNewBuddy) { try { FacebookPost.CreateNewBuddy(buddyUsr, this, false); } catch { } } } catch (BobNotFound) { if (source == AddBuddySource.BuddyButtonClick || source == AddBuddySource.UsrPageSendPrivateMessage) { Usr.IncrementSpamBotDefeaterCounter(SpamBotDefeaterCounter.BuddyRequests, this.K); } b.CanInvite = false; b.FullBuddy = false; if (sendNotificationEmailIfNewBuddyRequest) { Mailer m = new Mailer(); m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser; m.Subject = this.NickName + " has invited you to " + this.HisString(false) + " buddy list"; if (this.HasPic) { m.Body += "<a href=\"[LOGIN(" + this.Url() + ")]\"><img src=\"" + this.PicPath + "\" style=\"margin-left:5px;\" class=\"BorderBlack All\" width=\"100\" height=\"100\" align=\"right\" vspace=\"6\" border=\"0\"></a>"; } m.Body += "<h1>" + HttpUtility.HtmlEncode(this.NickName) + " has invited you to " + this.HisString(false) + " buddy list</h1>"; m.Body += "<p>Name: <a href=\"[LOGIN(" + this.Url() + ")]\">" + HttpUtility.HtmlEncode(this.FirstName) + " " + HttpUtility.HtmlEncode(this.LastName) + "</a>.</p>"; m.Body += "<p>To add " + HttpUtility.HtmlEncode(this.NickName) + " to your buddy list, view " + this.HisString(false) + " <a href=\"[LOGIN(" + this.Url() + ")]\">profile</a> and click the \"Add " + HttpUtility.HtmlEncode(this.NickName) + " to my buddy list\" button.</p>"; m.OverrideLoginLink = buddyUsr.LoginAndTransfer(this.Url()); m.UsrRecipient = buddyUsr; m.To = buddyUsr.Email; m.Send(); } } b.Update(); b.Usr.UpdateBuddyCount(null); b.BuddyUsr.UpdateBuddyCount(null); } }
public void SetBuddyInvite(Usr buddyUsr, bool allowBuddyInvite, AddBuddySource source, string skeletonName) { SetBuddyInvite(buddyUsr, allowBuddyInvite, source, null, skeletonName); }
public void AddBuddy(Usr buddyUsr, bool canBuddyInvite, AddBuddySource source, Buddy.BuddyFindingMethod foundByMethod, string skeletonName) { AddBuddy(buddyUsr, canBuddyInvite, true, source, foundByMethod, skeletonName); }