diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 00c6b356..647fa856 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -80,6 +80,10 @@ class Api::BaseController < ApplicationController # : todo : when figure out email/catpcha, put this back # elsif !current_user.confirmed? # render json: { error: 'Your login is missing a confirmed e-mail address' }, status: 403 + elsif current_user.account.is_flagged_as_spam? + render json: { error: 'Your account has been flagged as spam. Please contact support@gab.com if you believe this is an error.' }, status: 403 + elsif !current_user.approved? + render json: { error: 'Your login is currently pending approval' }, status: 403 else set_user_activity end diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 09ae8701..ab4bbeb6 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -10,6 +10,7 @@ class Api::V1::AccountsController < Api::BaseController before_action :require_user!, except: [:show, :create] before_action :set_account, except: [:create] before_action :check_account_suspension, only: [:show] + before_action :check_enabled_registrations, only: [:create] def show render json: @account, serializer: REST::AccountSerializer @@ -75,4 +76,12 @@ class Api::V1::AccountsController < Api::BaseController def account_params params.permit(:username, :email, :password, :agreement, :locale) end + + def check_enabled_registrations + forbidden if single_user_mode? || !allowed_registrations? + end + + def allowed_registrations? + Setting.registrations_mode != 'none' + end end diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb similarity index 66% rename from app/controllers/api/v1/bookmarks_controller.rb rename to app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb index f6aed818..6f56912e 100644 --- a/app/controllers/api/v1/bookmarks_controller.rb +++ b/app/controllers/api/v1/bookmark_collections/bookmarks_controller.rb @@ -1,16 +1,17 @@ # frozen_string_literal: true -class Api::V1::BookmarksController < Api::BaseController +class Api::V1::BookmarkCollections::BookmarksController < Api::BaseController before_action -> { doorkeeper_authorize! :read, :'read:bookmarks' } before_action :require_user! after_action :insert_pagination_headers def index - @statuses = [] if current_account.is_pro @statuses = load_statuses + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + else + render json: { error: 'You need to be a GabPRO member to access this' }, status: 422 end - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) end private @@ -42,11 +43,11 @@ class Api::V1::BookmarksController < Api::BaseController end def next_path - api_v1_bookmarks_url pagination_params(max_id: pagination_max_id) if records_continue? + api_v1_bookmark_collection_bookmarks_url pagination_params(max_id: pagination_max_id) if records_continue? end def prev_path - api_v1_bookmarks_url pagination_params(since_id: pagination_since_id) unless results.empty? + api_v1_bookmark_collection_bookmarks_url pagination_params(since_id: pagination_since_id) unless results.empty? end def pagination_max_id diff --git a/app/controllers/api/v1/bookmark_collections_controller.rb b/app/controllers/api/v1/bookmark_collections_controller.rb index ea1f77a6..4be0ec47 100644 --- a/app/controllers/api/v1/bookmark_collections_controller.rb +++ b/app/controllers/api/v1/bookmark_collections_controller.rb @@ -3,24 +3,24 @@ class Api::V1::BookmarkCollectionsController < Api::BaseController before_action :require_user! before_action :set_bookmark_collections, only: :index - before_action :set_bookmark_collection, only: [:show, :update, :destroy] + before_action :set_bookmark_collection, only: [:show, :update, :destroy, :update_status] def index - render json: @bookmark_collections, each_serializer: REST::BookmarkCollectionSerializer + render json: @bookmark_collections, each_serializer: REST::StatusBookmarkCollectionSerializer end def create - @bookmark_collection = "" #current_account.custom_filters.create!(resource_params) - render json: @bookmark_collection, serializer: REST::BookmarkCollectionSerializer + @bookmark_collection = current_account.status_bookmark_collections.create!(resource_params) + render json: @bookmark_collection, serializer: REST::StatusBookmarkCollectionSerializer end def show - render json: @bookmark_collection, serializer: REST::BookmarkCollectionSerializer + render json: @bookmark_collection, serializer: REST::StatusBookmarkCollectionSerializer end def update @bookmark_collection.update!(resource_params) - render json: @bookmark_collection, serializer: REST::BookmarkCollectionSerializer + render json: @bookmark_collection, serializer: REST::StatusBookmarkCollectionSerializer end def destroy @@ -28,14 +28,18 @@ class Api::V1::BookmarkCollectionsController < Api::BaseController render_empty_success end + def update_status + # + end + private def set_bookmark_collections - @bookmark_collections = "" #current_account.custom_filters + @bookmark_collections = current_account.status_bookmark_collections end def set_bookmark_collection - @bookmark_collection = "" # current_account.custom_filters.find(params[:id]) + @bookmark_collection = current_account.status_bookmark_collections.find(params[:id]) end def resource_params diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index 6f1d41b1..1c51b4f0 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -4,6 +4,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController layout :determine_layout before_action :set_challenge, only: [:new] + before_action :check_enabled_registrations, only: [:new, :create] before_action :configure_sign_up_params, only: [:create] before_action :set_sessions, only: [:edit, :update] before_action :set_instance_presenter, only: [:new, :create, :update] @@ -90,4 +91,13 @@ class Auth::RegistrationsController < Devise::RegistrationsController def set_cache_headers response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate' end + + def check_enabled_registrations + redirect_to root_path if single_user_mode? || !allowed_registrations? + end + + def allowed_registrations? + Setting.registrations_mode != 'none' + end + end diff --git a/app/controllers/manifests_controller.rb b/app/controllers/manifests_controller.rb index 09985129..238469a5 100644 --- a/app/controllers/manifests_controller.rb +++ b/app/controllers/manifests_controller.rb @@ -3,7 +3,7 @@ class ManifestsController < EmptyController def show - render json: InstancePresenter.new, serializer: ManifestSerializer + render json: {} #InstancePresenter.new, serializer: ManifestSerializer end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 86a5a0d4..d9b2b692 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -104,4 +104,17 @@ module ApplicationHelper # : todo : return 'white' end + + def open_registrations? + Setting.registrations_mode == 'open' + end + + def approved_registrations? + Setting.registrations_mode == 'approved' + end + + def closed_registrations? + Setting.registrations_mode == 'none' + end + end diff --git a/app/javascript/gabsocial/actions/albums.js b/app/javascript/gabsocial/actions/albums.js index ab0c0141..478a7f98 100644 --- a/app/javascript/gabsocial/actions/albums.js +++ b/app/javascript/gabsocial/actions/albums.js @@ -1 +1,16 @@ -// \ No newline at end of file +import api, { getLinks } from '../api' +import { me } from '../initial_state' + +// + +export const ALBUMS_FETCH_REQUEST = 'ALBUMS_FETCH_REQUEST' +export const ALBUMS_FETCH_SUCCESS = 'ALBUMS_FETCH_SUCCESS' +export const ALBUMS_FETCH_FAIL = 'ALBUMS_FETCH_FAIL' + +export const ALBUMS_CREATE_REQUEST = 'ALBUMS_CREATE_REQUEST' +export const ALBUMS_CREATE_SUCCESS = 'ALBUMS_CREATE_SUCCESS' +export const ALBUMS_CREATE_FAIL = 'ALBUMS_CREATE_FAIL' + +export const ALBUMS_REMOVE_REQUEST = 'ALBUMS_REMOVE_REQUEST' +export const ALBUMS_REMOVE_SUCCESS = 'ALBUMS_REMOVE_SUCCESS' +export const ALBUMS_REMOVE_FAIL = 'ALBUMS_REMOVE_FAIL' \ No newline at end of file diff --git a/app/javascript/gabsocial/actions/bookmarks.js b/app/javascript/gabsocial/actions/bookmarks.js index e04dd817..99cc9a48 100644 --- a/app/javascript/gabsocial/actions/bookmarks.js +++ b/app/javascript/gabsocial/actions/bookmarks.js @@ -40,13 +40,13 @@ export const UPDATE_BOOKMARK_COLLECTION_STATUS_SUCCESS = 'UPDATE_BOOKMARK_COLLEC export const fetchBookmarkedStatuses = (bookmarkCollectionId) => (dispatch, getState) => { if (!me) return - if (getState().getIn(['status_lists', 'bookmarks', 'isLoading'])) { + if (getState().getIn(['status_lists', 'bookmarks', bookmarkCollectionId, 'isLoading'])) { return } dispatch(fetchBookmarkedStatusesRequest(bookmarkCollectionId)) - api(getState).get('/api/v1/bookmarks').then((response) => { + api(getState).get(`/api/v1/bookmark_collections/${bookmarkCollectionId}/bookmarks`).then((response) => { const next = getLinks(response).refs.find(link => link.rel === 'next') dispatch(importFetchedStatuses(response.data)) dispatch(fetchBookmarkedStatusesSuccess(response.data, bookmarkCollectionId, next ? next.uri : null)) @@ -57,6 +57,7 @@ export const fetchBookmarkedStatuses = (bookmarkCollectionId) => (dispatch, getS const fetchBookmarkedStatusesRequest = (bookmarkCollectionId) => ({ type: BOOKMARKED_STATUSES_FETCH_REQUEST, + bookmarkCollectionId, }) const fetchBookmarkedStatusesSuccess = (statuses, bookmarkCollectionId, next) => ({ @@ -98,10 +99,12 @@ export const expandBookmarkedStatuses = (bookmarkCollectionId) => (dispatch, get const expandBookmarkedStatusesRequest = (bookmarkCollectionId) => ({ type: BOOKMARKED_STATUSES_EXPAND_REQUEST, + bookmarkCollectionId, }) const expandBookmarkedStatusesSuccess = (statuses, bookmarkCollectionId, next) => ({ type: BOOKMARKED_STATUSES_EXPAND_SUCCESS, + bookmarkCollectionId, statuses, next, }) @@ -213,7 +216,7 @@ export const updateBookmarkCollection = (bookmarkCollectionId, title) => (dispat dispatch(updateBookmarkCollectionRequest()) - api(getState).post('/api/v1/bookmark_collections', { title }).then((response) => { + api(getState).put('/api/v1/bookmark_collections', { title }).then((response) => { dispatch(updateBookmarkCollectionSuccess(response.data)) }).catch((error) => { dispatch(updateBookmarkCollectionFail(error)) @@ -243,8 +246,9 @@ export const updateBookmarkCollectionStatus = (statusId, bookmarkCollectionId) = dispatch(updateBookmarkCollectionStatusRequest()) - api(getState).post('/api/v1/bookmark_collections', { title }).then((response) => { - dispatch(updateBookmarkCollectionStatusSuccess(response.data)) + api(getState).post(`/api/v1/bookmark_collections/${bookmarkCollectionId}/update_status`, { statusId }).then((response) => { + dispatch(importFetchedStatuses([response.data])) + dispatch(updateBookmarkCollectionStatusSuccess()) }).catch((error) => { dispatch(updateBookmarkCollectionStatusFail(error)) }) @@ -254,9 +258,8 @@ const updateBookmarkCollectionStatusRequest = () => ({ type: UPDATE_BOOKMARK_COLLECTION_STATUS_REQUEST, }) -const updateBookmarkCollectionStatusSuccess = (bookmarkCollection) => ({ +const updateBookmarkCollectionStatusSuccess = () => ({ type: UPDATE_BOOKMARK_COLLECTION_STATUS_SUCCESS, - bookmarkCollection, }) const updateBookmarkCollectionStatusFail = (error) => ({ diff --git a/app/javascript/gabsocial/components/modal/bookmark_collection_edit_modal.js b/app/javascript/gabsocial/components/modal/bookmark_collection_edit_modal.js new file mode 100644 index 00000000..7d5afbf6 --- /dev/null +++ b/app/javascript/gabsocial/components/modal/bookmark_collection_edit_modal.js @@ -0,0 +1,29 @@ +import React from 'react' +import PropTypes from 'prop-types' +import { defineMessages, injectIntl } from 'react-intl' +import ModalLayout from './modal_layout' +import BookmarkCollectionEdit from '../../features/bookmark_collection_edit' + +class BookmarkCollectionEditModal extends React.PureComponent { + + render() { + const { onClose } = this.props + + return ( + + + + ) + } + +} + +BookmarkCollectionEditModal.propTypes = { + onClose: PropTypes.func.isRequired, +} + +export default BookmarkCollectionEditModal \ No newline at end of file diff --git a/app/javascript/gabsocial/components/modal/edit_profile_modal.js b/app/javascript/gabsocial/components/modal/edit_profile_modal.js index c2993d7c..90b55644 100644 --- a/app/javascript/gabsocial/components/modal/edit_profile_modal.js +++ b/app/javascript/gabsocial/components/modal/edit_profile_modal.js @@ -164,6 +164,7 @@ class EditProfileModal extends ImmutablePureComponent { diff --git a/app/javascript/gabsocial/components/navigation_bar/profile_navigation_bar.js b/app/javascript/gabsocial/components/navigation_bar/profile_navigation_bar.js index 6f11db5e..ff5990ad 100644 --- a/app/javascript/gabsocial/components/navigation_bar/profile_navigation_bar.js +++ b/app/javascript/gabsocial/components/navigation_bar/profile_navigation_bar.js @@ -33,7 +33,7 @@ class ProfileNavigationBar extends React.PureComponent { - - } { !paused && true && } -