async public Task <ChallengeDto> AcceptChallenge(string id) { var challenge = _context.Challenges.SingleOrDefault(c => c.Id == id); if (challenge == null) { throw "This challenge no longer exists".ToException(Request); } _authController.EnsureHasPermission(challenge.ChallengeeAthlete, Request); challenge.DateAccepted = DateTime.UtcNow; await _context.SaveChangesAsync(); var league = _context.Leagues.SingleOrDefault(l => l.Id == challenge.LeagueId); var challengee = _context.Athletes.SingleOrDefault(a => a.Id == challenge.ChallengeeAthleteId); var message = "{0}: Your challenge with {1} has been accepted!".Fmt(league.Name, challengee.Alias); var payload = new NotificationPayload { Action = PushActions.ChallengeAccepted, Payload = { { "challengeId", id }, { "leagueId", challenge.LeagueId } } }; await _notificationController.NotifyByTag(message, challenge.ChallengerAthleteId, payload); return(challenge.ToChallengeDto()); }
public PushModel PushNotification(PushModel model) { try { Boolean bsandbox = true; string p12fileName = Server.MapPath("~/Upload/Prosoft/iOS/ck_dev.pem"); string p12password = "******"; string deviceID1 = "ee98207ba890fe56bc6402991d03334f199688fbef943a9da7a33a0565c740d0"; // string alert = model.message + " at " + DateTime.Now.ToLongTimeString(); string soundstring = "default"; var payload1 = new NotificationPayload(deviceID1, alert, model.badge, soundstring); var notificationList = new List <NotificationPayload> { payload1 }; var push = new PushNotification(bsandbox, p12fileName, p12password); var rejected = push.SendToApple(notificationList); model.IsResult = true; } catch (Exception ex) { model.MsgError.Add(ex); model.IsResult = true; } return(model); }
async Task DeleteMembershipInternal(string id) { lock (_deleteSync) { var membership = _context.Memberships.SingleOrDefault(m => m.Id == id); //Need to remove all the ongoing challenges (not past challenges since those should be locked and sealed in time for eternity for all to see) var challenges = _context.Challenges.Where(c => c.LeagueId == membership.LeagueId && c.DateCompleted == null && (c.ChallengerAthleteId == membership.AthleteId || c.ChallengeeAthleteId == membership.AthleteId)).ToList(); foreach (var c in challenges) { try { var league = _context.Leagues.SingleOrDefault(l => l.Id == c.LeagueId); var payload = new NotificationPayload { Action = PushActions.ChallengeDeclined, Payload = { { "leagueId", c.LeagueId }, { "challengeId", c.Id } } }; var message = "You challenge with {0} has ben removed because they abandoned the {1} league".Fmt(membership.Athlete.Alias, league.Name); _notificationController.NotifyByTag(message, c.Opponent(membership.AthleteId).Id, payload); } catch (Exception e) { //TODO log to Insights Console.WriteLine(e); } } membership.AbandonDate = DateTime.UtcNow; challenges.ForEach(c => c.Deleted = true); _context.SaveChanges(); } }
public async Task NagAthlete(string challengeId) { var challenge = Lookup(challengeId).Queryable.FirstOrDefault(); if (challenge == null) { throw "This challenge no longer exists".ToException(Request); } var challenger = _context.Athletes.SingleOrDefault(a => a.Id == challenge.ChallengerAthleteId); if (challenger == null) { throw "The challenger no longer exists".ToException(Request); } var message = "{0} would be much obliged if you'd accept their challenge.".Fmt(challenger.Alias); var payload = new NotificationPayload { Action = PushActions.ChallengePosted, Payload = { { "challengeId", challengeId }, { "leagueId", challenge.LeagueId } } }; await _notificationController.NotifyByTag(message, challenge.ChallengeeAthleteId, payload); }
/// <summary> /// 產生本地端的推播通知 /// </summary> /// <param name="notificationPayload"></param> void createNotification(NotificationPayload notificationPayload) { #region 產生本地端的推播通知 #region 產生一個 Intent ,並且將要傳遞過去的推播參數,使用 PutExtra 放進去 var uiIntent = new Intent(this, typeof(MainActivity)); // 設定當使用點選這個通知之後,要傳遞過去的資料 var fooPayload = JsonConvert.SerializeObject(notificationPayload); uiIntent.PutExtra("NotificationPayload", fooPayload); #endregion //建立 Notification Builder 物件 Notification.Builder builder = new Notification.Builder(this); //設定本地端推播的內容 var notification = builder // 設定當點選這個本地端通知項目後,要顯示的 Activity .SetContentIntent(PendingIntent.GetActivity(this, 0, uiIntent, PendingIntentFlags.OneShot)) .SetSmallIcon(Android.Resource.Drawable.SymActionEmail) .SetTicker(notificationPayload.Title) .SetContentTitle(notificationPayload.Title) .SetContentText(notificationPayload.Message) //設定推播聲音 .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) //當使用者點選這個推播通知,將會自動移除這個通知 .SetAutoCancel(true).Build(); //產生 notification 物件 var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager; // 顯示本地通知: notificationManager.Notify(1, notification); #endregion }
public async Task NudgeAthlete(string challengeId) { if (Startup.IsDemoMode) { throw "Nudging is disabled in Demo Mode.".ToException(Request); } var challenge = Lookup(challengeId).Queryable.FirstOrDefault(); if (challenge == null) { throw "This challenge no longer exists".ToException(Request); } _authController.EnsureHasPermission(challenge.ChallengerAthlete, Request); if (challenge.ChallengerAthlete == null) { throw "The challenger no longer exists".ToException(Request); } var message = "{0} would be much obliged if you'd accept their challenge.".Fmt(challenge.ChallengerAthlete.Alias); var payload = new NotificationPayload { Action = PushActions.ChallengePosted, Payload = { { "challengeId", challengeId }, { "leagueId", challenge.LeagueId } } }; await _notificationController.NotifyByTag(message, challenge.ChallengeeAthleteId, payload); }
public async Task NotifyByTags(string message, List <string> tags, NotificationPayload payload = null, int?badgeCount = null) { var notification = new Dictionary <string, string> { { "message", message } }; if (payload != null) { var json = JsonConvert.SerializeObject(payload); notification.Add("payload", json); } else { notification.Add("payload", ""); } if (badgeCount == null) { badgeCount = 0; } notification.Add("badge", badgeCount.Value.ToString()); try { await _hub.SendTemplateNotificationAsync(notification, tags); } catch (Exception e) { Console.WriteLine(e); } }
public IActionResult SendNotification(NotificationPayload notificationPayload) { try { Sensor sensor = _db.Sensors.FirstOrDefault(s => s.DeviceId == notificationPayload.deviceId); if (sensor == null) { return(new StatusCodeResult(404)); } using (var client = new WebClient()) { var vm = new { app_id = _appId, data = new { tip = "confirmare", solicitantId = notificationPayload.userId, notificationPayload.hours, notificationPayload.deviceId }, contents = new { en = notificationPayload.text }, include_player_ids = new[] { sensor.OwnerId }, buttons = new[] { new { id = "yes", text = "Da" }, new { id = "no", text = "Nu" } } }; var dataString = JsonConvert.SerializeObject(vm); client.Headers.Add(HttpRequestHeader.ContentType, "application/json"); client.Headers.Add(HttpRequestHeader.Authorization, "Basic MDMxMjg4OTYtMTlkOC00ZjJiLTkzOTMtZmQ4NWZhYmQwNWNk"); string res = client.UploadString(new Uri("https://onesignal.com/api/v1/notifications"), "POST", dataString); return(Ok(res)); } } catch (Exception ex) { return(Ok("error. notif text: " + notificationPayload)); } }
public async Task <ActionResult> Notify(string validationToken) { // Check if this is a validation request. if (!string.IsNullOrEmpty(validationToken)) { // To validate return the validationToken back in the response return(Content(validationToken, "text/plain")); } // If it's not a validation request, then this is a notification. Stream postBody = Request.InputStream; postBody.Seek(0, SeekOrigin.Begin); string notificationJson = new StreamReader(postBody).ReadToEnd(); NotificationPayload notification = JsonConvert.DeserializeObject <NotificationPayload>(notificationJson); string userId = await UserManager.UpdateInboxBySubscription(notification.Notifications[0].SubscriptionId); if (!string.IsNullOrEmpty(userId)) { var hub = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); string connId = await UserManager.GetUserSignalRConnection(userId); hub.Clients.Client(connId).refreshInboxPage(); } return(Content("")); }
private async Task SendPushToAppCenter(string title, string content, string surveyid) { var notification = new NotificationPayload { NotificationContent = new NotificationContent { Body = content, Name = title, Title = title, CustomData = new CustomData { QuestionaryId = surveyid } } }; using (var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) }) { client.DefaultRequestHeaders.Add("X-API-Token", "<X-API-Token>"); var builder = new UriBuilder(new Uri("https://appcenter.ms/api/v0.1/apps/***app/Notifications-android/push/notifications")); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, builder.Uri) { Content = new StringContent(JsonConvert.SerializeObject(notification), Encoding.UTF8, "application/json") }; var msg = await client.SendAsync(request); Console.WriteLine(msg); } }
public async Task <IActionResult> CreateConversation([FromBody] CreateConversationDto conversationDto) { try { return(await createConversationControllerTimeMetric.TrackTime(async() => { string id = GenerateConversationId(conversationDto); var currentTime = DateTime.UtcNow; Conversation conversation = new Conversation(id, conversationDto.Participants, currentTime); await conversationsStore.AddConversation(conversation); logger.LogInformation(Events.ConversationCreated, "Conversation with id {conversationId} was created"); var newConversationPayload = new NotificationPayload(currentTime, "ConversationAdded", id, conversationDto.Participants); await notificationService.SendNotificationAsync(newConversationPayload); return Ok(conversation); })); } catch (StorageErrorException e) { logger.LogError(Events.StorageError, e, "Could not reach storage to add user conversation"); return(StatusCode(503, "Could not reach storage to add user conversation")); } catch (Exception e) { logger.LogError(Events.InternalError, e, "Failed to add conversation"); return(StatusCode(500, "Failed to add conversation")); } }
public void HasErrorAlertEmpty() { var payload = new NotificationPayload(); payload.Alert = new Dictionary <string, object>(); Assert.False(payload.HasError()); }
public static OutboundComm CreateNotificationAttestationNeeded(FinancialAccount budget, Person concernedPerson, string supplier, double amountRequested, string purpose, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); payload.Strings[NotificationString.RequestPurpose] = purpose; payload.Strings[NotificationString.Description] = purpose; payload.Strings[NotificationString.Supplier] = supplier; payload.Strings[NotificationString.BudgetName] = budget.Name; payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical; OutboundComm comm = OutboundComm.Create(null, null, budget.Organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); if (budget.OwnerPersonId == 0) { comm.AddRecipient(Person.FromIdentity(1)); // Add admin - not good, should be org admins // HACK // TODO } else { comm.AddRecipient(budget.Owner); } comm.Resolved = true; return(comm); }
public void PublishNotification(IEnumerable <Notification> notifications, INotificationRecipients recipients, NotificationSchedulerSettings schedulerSettings = null) { var payload = new NotificationPayload(); foreach (Notification notification in notifications) { payload.Payloads.Add(notification.NotifierIdentifier, notification.GetPayload()); } if (schedulerSettings != null) { if (schedulerSettings.DeliverAt != DateTime.MinValue) { payload.DeliverAt = schedulerSettings.DeliverAt.ToUnixTime(); } if (schedulerSettings.ExpireAt != DateTime.MinValue) { payload.ExpireAt = schedulerSettings.ExpireAt.ToUnixTime(); } } string query = recipients.BuildQuery(); IRestResponse response = Request.ExecuteJsonRequest(query, Method.POST, payload); ValidateResponse(response); }
public async Task <Message> PostMessage(string conversationId, SendMessageDtoV2 messageDto) { var matchingMessage = await conversationsStore.TryGetMessage(conversationId, messageDto.MessageId); if (matchingMessage.found) // if the message was found in storage { return(matchingMessage.message); } var currentTime = DateTime.Now; var message = new Message(messageDto.Text, messageDto.SenderUsername, currentTime); await conversationsStore.AddMessage(conversationId, messageDto.MessageId, message); logger.LogInformation(Events.ConversationMessageAdded, "Message {MessageId} has been added to conversation {conversationId}, sender: {senderUsername}", messageDto.MessageId, conversationId, messageDto.SenderUsername); var conversation = await conversationsStore.GetConversation(messageDto.SenderUsername, conversationId); var usersToNotify = conversation.Participants; var newMessagePayload = new NotificationPayload(currentTime, "MessageAdded", conversationId, usersToNotify); await notificationService.SendNotificationAsync(newMessagePayload); return(message); }
public static OutboundComm CreateNotificationOfFinancialValidation(FinancialAccount budget, Person concernedPerson, double amountRequested, string purpose, NotificationResource notification, string reasonGiven = "") { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.DisplayCode; payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString("N2"); payload.Strings[NotificationString.RequestPurpose] = purpose; payload.Strings[NotificationString.BudgetName] = budget.Name; payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical; payload.Strings[NotificationString.EmbeddedPreformattedText] = reasonGiven; OutboundComm comm = OutboundComm.Create(null, null, budget.Organization, null, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); comm.AddRecipient(concernedPerson); comm.Resolved = true; return(comm); }
public static OutboundComm CreateNotificationFinancialValidationNeeded(Organization organization, double amountRequested, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = organization.Currency.DisplayCode; payload.Strings[NotificationString.OrganizationName] = organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString("N2"); OutboundComm comm = OutboundComm.Create(null, null, organization, null, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); People validators = organization.ValidatingPeople; foreach (Person validator in validators) { comm.AddRecipient(validator); } comm.Resolved = true; return(comm); }
private void CheckArguments(NotificationPayload payload) { if (payload == null) { throw new ArgumentNullException(nameof(payload)); } if (payload.Users == null || payload.Users.Length == 0) { throw new ArgumentNullException(nameof(payload.Users)); } foreach (var username in payload.Users) { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException(nameof(username)); } } if (string.IsNullOrWhiteSpace(payload.ConversationId)) { throw new ArgumentNullException(nameof(payload.ConversationId)); } if (string.IsNullOrWhiteSpace(payload.Type)) { throw new ArgumentNullException(nameof(payload.Type)); } if (payload.UtcTime == null) { throw new ArgumentNullException(nameof(payload.UtcTime)); } }
public PushModel TestPushPro(PushModel model) { try { Boolean bsandbox = false; string p12fileName = Server.MapPath("~/Upload/Prosoft/iOS/ck_pro.pem"); string deviceID1 = "5c13e113f17582641b3eaca090c387a6ce11f86f5ead096283e1d5a9e91e8937"; // string p12password = "******"; string alert = model.message + " at " + DateTime.Now.ToLongTimeString(); string soundstring = "default"; var payload1 = new NotificationPayload(deviceID1, alert, model.badge, soundstring); payload1.AddCustom("custom1", model.message); var notificationList = new List <NotificationPayload> { payload1 }; var push = new PushNotification(bsandbox, p12fileName, p12password); var rejected = push.SendToApple(notificationList); model.IsResult = true; } catch (Exception ex) { model.MsgError.Add(ex); model.IsResult = false; } return(model); }
public async Task SendNotificationAsync(NotificationPayload payload) { CheckArguments(payload); var jsonPayload = JsonConvert.SerializeObject(payload); var message = new Message(Encoding.UTF8.GetBytes(jsonPayload)); await queueClient.SendAsync(message); }
private void CreatePushNotification(string notificationtext, string devicetoken) { var payload1 = new NotificationPayload(devicetoken, notificationtext, 1, "default", 1); var notificationList = new List <NotificationPayload> { payload1 }; var push = new PushNotification(UseAppleSandbox, CertPath, CertPassword); var rejected = push.SendToApple(notificationList); }
protected override async void OnIncomingPayload(App app, NotificationPayload payload) { string challengeId = null; if (payload.Payload.TryGetValue("challengeId", out challengeId)) { await RemoteRefresh(); } }
private async Task SendMessageAsync(string endPoint, NotificationPayload message) { byte[] toSend = message.ToByteArray(); foreach (var session in _repository.GetSessionWithoutProducer(endPoint)) //DONT send message by yourself { await Client.SendAsync(toSend, toSend.Length, session.EndPoint); } }
// POST tables/Challenge public async Task <IHttpActionResult> PostChallenge(ChallengeDto item) { var challenger = _context.Athletes.SingleOrDefault(a => a.Id == item.ChallengerAthleteId); var challengee = _context.Athletes.SingleOrDefault(a => a.Id == item.ChallengeeAthleteId); _authController.EnsureHasPermission(challenger, Request); if (challenger == null || challengee == null) { throw "The opponent in this challenge no longer belongs to this league.".ToException(Request); } var challengerMembership = _context.Memberships.SingleOrDefault(m => m.AbandonDate == null && m.AthleteId == challenger.Id && m.LeagueId == item.LeagueId); var challengeeMembership = _context.Memberships.SingleOrDefault(m => m.AbandonDate == null && m.AthleteId == challengee.Id && m.LeagueId == item.LeagueId); if (challengerMembership == null || challengeeMembership == null) { throw "The opponent in this challenge no longer belongs to this league.".ToException(Request); } //Check to see if there are any ongoing challenges between both athletes var challengeeOngoing = _context.Challenges.Where(c => ((c.ChallengeeAthleteId == item.ChallengeeAthleteId || c.ChallengerAthleteId == item.ChallengeeAthleteId) && (c.ChallengeeAthleteId == item.ChallengerAthleteId || c.ChallengerAthleteId == item.ChallengerAthleteId) && c.LeagueId == item.LeagueId && c.DateCompleted == null) && !c.Deleted); if (challengeeOngoing.Count() > 0) { throw "{0} already has an existing challenge underway with {1}.".Fmt(challengee.Alias, challenger.Alias).ToException(Request); } var league = _context.Leagues.SingleOrDefault(l => l.Id == item.LeagueId); try { var challenge = item.ToChallenge(); var json = Newtonsoft.Json.JsonConvert.SerializeObject(challenge); Challenge current = await InsertAsync(challenge); var result = CreatedAtRoute("Tables", new { id = current.Id }, current.ToChallengeDto()); var message = "{0}: You have been challenged to a duel by {1}!".Fmt(league.Name, challenger.Alias); var payload = new NotificationPayload { Action = PushActions.ChallengePosted, Payload = { { "challengeId", current.Id }, { "leagueId", current.LeagueId } } }; _notificationController.NotifyByTag(message, current.ChallengeeAthleteId, payload); return(result); } catch (Exception e) { return(null); } //Not awaiting so the user's result is not delayed }
public TopicUnicastMessage(FcmMessageOptions options, Topic topic, NotificationPayload notification) : base(options, notification) { if (topic == null) { throw new ArgumentNullException("topic"); } To = topic.getTopicPath(); }
public void HasErrorAlertNoneError() { var payload = new NotificationPayload(); payload.Alert = new Dictionary <string, object> { { "title", "title" } }; Assert.False(payload.HasError()); }
public void HasErrorAlertErrorKey() { var payload = new NotificationPayload(); payload.Alert = new Dictionary <string, object> { { "error", "error" } }; Assert.True(payload.HasError()); }
public FcmMessage(FcmMessageOptions options, NotificationPayload notification) { Notification = notification; CollapseKey = options.CollapseKey; Priority = options.PriorityEnum; ContentAvailable = options.ContentAvailable; DelayWhileIdle = options.DelayWhileIdle; TimeToLive = options.TimeToLive; DryRun = options.DryRun; }
private static OutboundComm CreateSingleRecipientNotification(NotificationPayload payload, Organization organization, Person addressee) { OutboundComm comm = OutboundComm.Create(null, null, organization, null, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); comm.AddRecipient(addressee); comm.Resolved = true; return(comm); }
void NotifyAboutNewLeagueOpenEnrollment(League league) { var date = league.StartDate.Value.DateTime.ToOrdinal(); var message = "Open enrollment for the {0} league has started. The league will begin on {1}".Fmt(league.Name, date); var payload = new NotificationPayload { Action = PushActions.LeagueStarted, Payload = { { "leagueId", league.Id } } }; _notificationController.NotifyByTag(message, "All", payload); }
public static OutboundComm CreateNotificationFinancialValidationNeeded (Organization organization, double amountRequested, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); OutboundComm comm = OutboundComm.Create(null, null, organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); People validators = organization.ValidatingPeople; foreach (Person validator in validators) { comm.AddRecipient(validator); } comm.Resolved = true; return comm; }
public static OutboundComm CreateNotificationOfFinancialValidation(FinancialAccount budget, Person concernedPerson, double amountRequested, string purpose, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); payload.Strings[NotificationString.RequestPurpose] = purpose; payload.Strings[NotificationString.BudgetName] = budget.Name; payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical; OutboundComm comm = OutboundComm.Create(null, null, budget.Organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); comm.AddRecipient(concernedPerson); comm.Resolved = true; return comm; }
public static OutboundComm CreateNotificationAttestationNeeded(FinancialAccount budget, Person concernedPerson, string supplier, double amountRequested, string purpose, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); payload.Strings[NotificationString.RequestPurpose] = purpose; payload.Strings[NotificationString.Description] = purpose; payload.Strings[NotificationString.Supplier] = supplier; payload.Strings[NotificationString.BudgetName] = budget.Name; payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical; OutboundComm comm = OutboundComm.Create(null, null, budget.Organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); if (budget.OwnerPersonId == 0) { comm.AddRecipient(Person.FromIdentity(1)); // Add admin - not good, should be org admins // HACK // TODO } else { comm.AddRecipient(budget.Owner); } comm.Resolved = true; return comm; }