idem
This commit is contained in:
@ -33,37 +33,17 @@ namespace Yavsc.Services
|
||||
public async Task<MessageWithPayloadResponse>
|
||||
NotifyAsync(GoogleAuthSettings googleSettings, IEnumerable<string> 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<bool> SendEmailAsync(SiteSettings siteSettings, SmtpSettings smtpSettings, string email, string subject, string message)
|
||||
public Task<bool> 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);
|
||||
|
Reference in New Issue
Block a user