Example #1
0
        public Task BanUser(Models.BannedEntity entity, string subname ) {
            if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true" ) )
                throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return dirtbag.BanUser( subname, entity.EntityString, entity.BanReason, entity.ThingID, ClaimsPrincipal.Current.Identity.Name );
        }
Example #2
0
 public Task UpdateBan(string subname, int id, [FromBody] string reason ) {
     if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true" ) )
         throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );
     
     BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
     return dirtbag.UpdateBanReason( subname, id, reason, ClaimsPrincipal.Current.Identity.Name );
 }
Example #3
0
        public Task<bool> RemoveBan(string subname, int id ) {
            if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true" ) )
                throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return dirtbag.RemoveBan( id, ClaimsPrincipal.Current.Identity.Name, subname );
        }
Example #4
0
        public Task<IEnumerable<Models.BannedEntity>> GetBanList(string subname ) {
            if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true" ) )
                throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return dirtbag.GetBanList( subname );
        }
Example #5
0
        public async Task<Models.DirtbagSettings> Update(Models.DirtbagSettings settings, string subname ) {
            if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true" ) )
                throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );

            if ( !settings.DirtbagUrl.EndsWith( "/" ) ) settings.DirtbagUrl = settings.DirtbagUrl + "/";
            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            await dirtbag.SaveSettings( settings, subname );
            return settings;
        }
Example #6
0
        public Task BanChannel(Models.BannedEntity entity, string subname)
        {
            if (!ClaimsPrincipal.Current.HasClaim($"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true"))
            {
                throw new UnauthorizedAccessException("You are not an admin of this subreddit!");
            }

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return(dirtbag.BanChannel(subname, entity.EntityString, entity.BanReason, entity.ThingID, ClaimsPrincipal.Current.Identity.Name));
        }
Example #7
0
        public Task UpdateBan(string subname, int id, [FromBody] string reason)
        {
            if (!ClaimsPrincipal.Current.HasClaim($"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true"))
            {
                throw new UnauthorizedAccessException("You are not an admin of this subreddit!");
            }

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return(dirtbag.UpdateBanReason(subname, id, reason, ClaimsPrincipal.Current.Identity.Name));
        }
Example #8
0
        public Task <bool> RemoveBan(string subname, int id)
        {
            if (!ClaimsPrincipal.Current.HasClaim($"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true"))
            {
                throw new UnauthorizedAccessException("You are not an admin of this subreddit!");
            }

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return(dirtbag.RemoveBan(id, ClaimsPrincipal.Current.Identity.Name, subname));
        }
Example #9
0
        public Task <IEnumerable <Models.BannedEntity> > GetBanList(string subname)
        {
            if (!ClaimsPrincipal.Current.HasClaim($"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true"))
            {
                throw new UnauthorizedAccessException("You are not an admin of this subreddit!");
            }

            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            return(dirtbag.GetBanList(subname));
        }
Example #10
0
        public async Task<bool> TestConnection(Models.DirtbagSettings settings, string subname ) {
            if ( !ClaimsPrincipal.Current.HasClaim( $"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true" ) )
                throw new UnauthorizedAccessException( "You are not an admin of this subreddit!" );

            if ( ! settings.DirtbagUrl.EndsWith( "/" ) ) settings.DirtbagUrl = settings.DirtbagUrl + "/";
            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            try {
                return await dirtbag.TestConnection( settings, subname );
            }
            catch (HttpRequestException ex) {
                throw new HttpResponseException( Request.CreateErrorResponse( HttpStatusCode.BadRequest, ex.GetBaseException().Message ) );
            }
            
        }
Example #11
0
        public async Task <Models.DirtbagSettings> Update(Models.DirtbagSettings settings, string subname)
        {
            if (!ClaimsPrincipal.Current.HasClaim($"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true"))
            {
                throw new UnauthorizedAccessException("You are not an admin of this subreddit!");
            }

            if (!settings.DirtbagUrl.EndsWith("/"))
            {
                settings.DirtbagUrl = settings.DirtbagUrl + "/";
            }
            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            await dirtbag.SaveSettings(settings, subname);

            return(settings);
        }
Example #12
0
        public async Task <bool> TestConnection(Models.DirtbagSettings settings, string subname)
        {
            if (!ClaimsPrincipal.Current.HasClaim($"urn:snoonotes:subreddits:{subname.ToLower()}:admin", "true"))
            {
                throw new UnauthorizedAccessException("You are not an admin of this subreddit!");
            }

            if (!settings.DirtbagUrl.EndsWith("/"))
            {
                settings.DirtbagUrl = settings.DirtbagUrl + "/";
            }
            BLL.DirtbagBLL dirtbag = new BLL.DirtbagBLL();
            try {
                return(await dirtbag.TestConnection(settings, subname));
            }
            catch (HttpRequestException ex) {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.GetBaseException().Message));
            }
        }