private static void removeDuplicateEvents(List<Event> events, Event e) { events.Remove(e); if (e.Type == eType.NewFriendRelationship) { events.RemoveAll(ev => ev.Type == eType.NewFriendRelationship && e.FromUsername == Misc.FromXml<NewFriendRelationship>(ev.DetailsXML).Username && ev.FromUsername == Misc.FromXml<NewFriendRelationship>(e.DetailsXML).Username); } else if (e.Type == eType.RemovedFriendRelationship) { events.RemoveAll(ev => ev.Type == eType.RemovedFriendRelationship && e.FromUsername == Misc.FromXml<RemovedFriendRelationship>(ev.DetailsXML).Username && ev.FromUsername == Misc.FromXml<RemovedFriendRelationship>(e.DetailsXML).Username); } else if (e.Type == eType.NewFriendFriend) { events.RemoveAll(ev => ev.Type == eType.NewFriendFriend && e.FromUsername == Misc.FromXml<NewFriendFriend>(ev.DetailsXML).Username && ev.FromUsername == Misc.FromXml<NewFriendFriend>(e.DetailsXML).Username); } else if (e.Type == eType.RemovedFriendFriend) { events.RemoveAll(ev => ev.Type == eType.RemovedFriendFriend && e.FromUsername == Misc.FromXml<RemovedFriendFriend>(ev.DetailsXML).Username && ev.FromUsername == Misc.FromXml<RemovedFriendFriend>(e.DetailsXML).Username); } }
protected void lnkUpdateStatusText_Click(object sender, EventArgs e) { string status = String.Empty; status = txtStatusText.Text.Trim(); if (status.Length > 0) { lblStatusText.Text = Server.HtmlEncode(status); CurrentUserSession.StatusText = status; CurrentUserSession.Update(); #region Add FriendUpdatedStatus Event & realtime notifications Event newEvent = new Event(CurrentUserSession.Username) { Type = Event.eType.FriendUpdatedStatus }; var friendUpdatedStatus = new FriendUpdatedStatus { Status = status }; newEvent.DetailsXML = Misc.ToXml(friendUpdatedStatus); newEvent.Save(); string[] usernames = Data.User.FetchMutuallyFriends(CurrentUserSession.Username); foreach (string friendUsername in usernames) { if (Config.Users.NewEventNotification && (Data.User.IsOnline(friendUsername) || Data.User.IsUsingNotifier(friendUsername))) { var text = String.Format("Your friend {0} has changed their status to \"{1}\"".Translate(), "<b>" + CurrentUserSession.Username + "</b>", status); var imageID = 0; try { imageID = CurrentUserSession.GetPrimaryPhoto().Id; } catch (NotFoundException) { imageID = ImageHandler.GetPhotoIdByGender(CurrentUserSession.Gender); } var thumbnailUrl = ImageHandler.CreateImageUrl(imageID, 50, 50, false, true, true); var notification = new GenericEventNotification { Recipient = friendUsername, Sender = CurrentUserSession.Username, Text = text, ThumbnailUrl = thumbnailUrl, RedirectUrl = UrlRewrite.CreateShowUserUrl(CurrentUserSession.Username) }; RealtimeNotification.SendNotification(notification); } } #endregion // Update Twitter status if (Config.Misc.EnableTwitterIntegration && Twitter.HasCredentials(CurrentUserSession.Username)) { try { Twitter.PublishTweet(CurrentUserSession.Username, status); } catch (Exception err) { Global.Logger.LogError("Twitter", err); } } } else { lblStatusText.Text = "Not set".Translate(); CurrentUserSession.StatusText = null; CurrentUserSession.Update(); } pnlEditStatusText.Visible = false; pnlViewStatusText.Visible = true; }
private static Event[] filterEvents(List<Event> events, Event e) { List<Event> result = null; result = events.Where(u => u.FromUsername == e.FromUsername && u.FromGroup == e.FromGroup && u.Type == e.Type && u.Date >= e.Date.AddDays(-1)).ToList(); events.RemoveAll(result.Contains); // if (e.Type == eType.NewFriendFriend) // { // events.RemoveAll(ev => ev.Type == eType.NewFriendFriend && // result.Exists( // r => r.FromUsername == Misc.FromXml<NewFriendFriend>(ev.DetailsXML).Username // && ev.FromUsername == Misc.FromXml<NewFriendFriend>(r.DetailsXML).Username)); // } // else if (e.Type == eType.RemovedFriendFriend) // { // events.RemoveAll(ev => ev.Type == eType.RemovedFriendFriend && // result.Exists( // r => r.FromUsername == Misc.FromXml<RemovedFriendFriend>(ev.DetailsXML).Username // && ev.FromUsername == Misc.FromXml<RemovedFriendFriend>(r.DetailsXML).Username)); // } // else if (e.Type == eType.NewFriendRelationship) // { // events.RemoveAll(ev => ev.Type == eType.NewFriendRelationship && // result.Exists( // r => r.FromUsername == Misc.FromXml<NewFriendRelationship>(ev.DetailsXML).Username // && ev.FromUsername == Misc.FromXml<NewFriendRelationship>(r.DetailsXML).Username)); // } // else if (e.Type == eType.RemovedFriendRelationship) // { // events.RemoveAll(ev => ev.Type == eType.RemovedFriendRelationship && // result.Exists( // r => r.FromUsername == Misc.FromXml<RemovedFriendRelationship>(ev.DetailsXML).Username // && ev.FromUsername == Misc.FromXml<RemovedFriendRelationship>(r.DetailsXML).Username)); // } return result.ToArray(); }