about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/apps_controller.rb13
-rw-r--r--app/controllers/api/statuses_controller.rb17
-rw-r--r--app/controllers/api_controller.rb4
-rw-r--r--app/controllers/auth/sessions_controller.rb6
-rw-r--r--app/controllers/home_controller.rb2
-rw-r--r--app/controllers/oauth/applications_controller.rb18
6 files changed, 41 insertions, 19 deletions
diff --git a/app/controllers/api/apps_controller.rb b/app/controllers/api/apps_controller.rb
new file mode 100644
index 000000000..629cb2416
--- /dev/null
+++ b/app/controllers/api/apps_controller.rb
@@ -0,0 +1,13 @@
+class Api::AppsController < ApplicationController
+  respond_to :json
+
+  def create
+    @app = Doorkeeper::Application.create!(app_params)
+  end
+
+  private
+
+  def app_params
+    params.permit(:name, :redirect_uri)
+  end
+end
diff --git a/app/controllers/api/statuses_controller.rb b/app/controllers/api/statuses_controller.rb
index f68f298d8..44fb40bae 100644
--- a/app/controllers/api/statuses_controller.rb
+++ b/app/controllers/api/statuses_controller.rb
@@ -17,16 +17,33 @@ class Api::StatusesController < ApiController
     render action: :show
   end
 
+  def destroy
+    @status = Status.where(account_id: current_user.account).find(params[:id])
+    RemoveStatusService.new.(@status)
+    render_empty
+  end
+
   def reblog
     @status = ReblogService.new.(current_user.account, Status.find(params[:id])).reload
     render action: :show
   end
 
+  def unreblog
+    RemoveStatusService.new.(Status.where(account_id: current_user.account, reblog_of_id: params[:id]).first!)
+    @status = Status.find(params[:id])
+    render action: :show
+  end
+
   def favourite
     @status = FavouriteService.new.(current_user.account, Status.find(params[:id])).status.reload
     render action: :show
   end
 
+  def unfavourite
+    @status = UnfavouriteService.new.(current_user.account, Status.find(params[:id])).status.reload
+    render action: :show
+  end
+
   def home
     @statuses = Feed.new(:home, current_user.account).get(20, params[:max_id]).to_a
   end
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index cbe7141b9..e3ac9fc67 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -27,4 +27,8 @@ class ApiController < ApplicationController
   def current_user
     super || current_resource_owner
   end
+
+  def render_empty
+    render json: {}, status: 200
+  end
 end
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
index fe0adc9bb..1418ab2ca 100644
--- a/app/controllers/auth/sessions_controller.rb
+++ b/app/controllers/auth/sessions_controller.rb
@@ -8,4 +8,10 @@ class Auth::SessionsController < Devise::SessionsController
       remember_me(resource)
     end
   end
+
+  protected
+
+  def after_sign_in_path_for(_resource)
+    root_path
+  end
 end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index f159c3df8..6b52b704d 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -7,7 +7,7 @@ class HomeController < ApplicationController
     @mentions     = Feed.new(:mentions, current_user.account).get(20)
     @token        = find_or_create_access_token.token
   end
-
+  
   private
 
   def find_or_create_access_token
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
deleted file mode 100644
index 47935bf7c..000000000
--- a/app/controllers/oauth/applications_controller.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
-  before_action :authenticate_user!
-
-  def index
-    @applications = current_user.oauth_applications
-  end
-
-  def create
-    @application = Doorkeeper::Application.new(application_params)
-    @application.owner = current_user
-
-    if @application.save
-      redirect_to oauth_application_url(@application)
-    else
-      render :new
-    end
-  end
-end