2017-08-10 14:39:11 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Bit.Core.Services;
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2017-08-10 15:26:05 -04:00
|
|
|
|
using Bit.Core;
|
|
|
|
|
|
using Bit.Core.Exceptions;
|
2017-08-10 14:39:11 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Api.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
[Route("push")]
|
|
|
|
|
|
[Authorize("Push")]
|
|
|
|
|
|
public class PushController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IPushRegistrationService _pushRegistrationService;
|
2017-08-10 15:26:05 -04:00
|
|
|
|
private readonly CurrentContext _currentContext;
|
2017-08-10 14:39:11 -04:00
|
|
|
|
|
|
|
|
|
|
public PushController(
|
2017-08-10 15:26:05 -04:00
|
|
|
|
IPushRegistrationService pushRegistrationService,
|
|
|
|
|
|
CurrentContext currentContext)
|
2017-08-10 14:39:11 -04:00
|
|
|
|
{
|
2017-08-10 15:26:05 -04:00
|
|
|
|
_currentContext = currentContext;
|
2017-08-10 14:39:11 -04:00
|
|
|
|
_pushRegistrationService = pushRegistrationService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("register")]
|
|
|
|
|
|
public Object Register()
|
|
|
|
|
|
{
|
2017-08-10 15:26:05 -04:00
|
|
|
|
if(!_currentContext.InstallationId.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new BadRequestException("bad request.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-10 14:39:11 -04:00
|
|
|
|
return new { Foo = "bar" };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|