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; }
/// <summary> /// Checks is the recipient is online and sends the online event notification. /// </summary> /// <param name="sender">The sender.</param> /// <param name="recipient">The recipient.</param> /// <param name="text">The text.</param> /// <param name="thumbnailUrl">The thumbnail URL.</param> /// <param name="redirectUrl">The redirect URL.</param> public static void SendOnlineEventNotification(string sender, string recipient, string text, string thumbnailUrl, string redirectUrl) { if (IsOnline(recipient) || IsUsingNotifier(recipient)) { var notification = new GenericEventNotification { Recipient = recipient, Sender = sender, Text = text, ThumbnailUrl = thumbnailUrl, RedirectUrl = redirectUrl }; RealtimeNotification.SendNotification(notification); } }