diff --git a/Yavsc/Services/MessageServices.cs b/Yavsc/Services/MessageServices.cs
index 85d00903..0c77631a 100755
--- a/Yavsc/Services/MessageServices.cs
+++ b/Yavsc/Services/MessageServices.cs
@@ -30,40 +30,20 @@ namespace Yavsc.Services
/// a MessageWithPayloadResponse,
/// bool somethingsent = (response.failure == 0 && response.success > 0)
///
- public async Task
+ public async Task
NotifyAsync(GoogleAuthSettings googleSettings, IEnumerable registrationIds, YaEvent ev)
{
- MessageWithPayloadResponse response;
- try
- {
- using (var web = new HttpClient())
- {
- response = await web.NotifyEvent(googleSettings, registrationIds, ev);
- }
- }
- catch (WebException ex)
- {
- string errorMsgGCM;
- using (var respstream = ex.Response.GetResponseStream())
- {
- using (StreamReader rdr = new StreamReader(respstream))
- {
- errorMsgGCM = rdr.ReadToEnd();
- rdr.Close();
- }
- respstream.Close();
- }
- if (errorMsgGCM == null)
- throw;
-
- throw new Exception(errorMsgGCM, ex);
- }
+ MessageWithPayloadResponse response = null;
+ await Task.Run(()=>{
+ response = googleSettings.NotifyEvent(registrationIds, ev);
+ });
return response;
}
- public Task SendEmailAsync(SiteSettings siteSettings, SmtpSettings smtpSettings, string email, string subject, string message)
+ public Task SendEmailAsync(SiteSettings siteSettings, SmtpSettings smtpSettings, string email, string subject, string message)
{
- try {
+ try
+ {
MimeMessage msg = new MimeMessage();
msg.From.Add(new MailboxAddress(
siteSettings.Owner.Name,
@@ -83,7 +63,8 @@ namespace Yavsc.Services
sc.Send(msg);
}
}
- catch (Exception) {
+ catch (Exception)
+ {
return Task.FromResult(false);
}
return Task.FromResult(true);