]> cat aescling's git repositories - mastodon.git/commitdiff
Add attribute for default privacy to verify credentials (#4075)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Mon, 10 Jul 2017 01:29:34 +0000 (10:29 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 10 Jul 2017 01:29:34 +0000 (03:29 +0200)
* Add attribute for default privacy to verify credentials

* add raw_note

* source

app/controllers/api/v1/accounts/credentials_controller.rb
app/serializers/rest/credential_account_serializer.rb [new file with mode: 0644]

index 8ee9a2416e9fa484fdfacbecfba5a10569abc6e5..073808532a519427cc3453a82716e195f3d2ff2f 100644 (file)
@@ -6,13 +6,13 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
 
   def show
     @account = current_account
-    render json: @account, serializer: REST::AccountSerializer
+    render json: @account, serializer: REST::CredentialAccountSerializer
   end
 
   def update
     current_account.update!(account_params)
     @account = current_account
-    render json: @account, serializer: REST::AccountSerializer
+    render json: @account, serializer: REST::CredentialAccountSerializer
   end
 
   private
diff --git a/app/serializers/rest/credential_account_serializer.rb b/app/serializers/rest/credential_account_serializer.rb
new file mode 100644 (file)
index 0000000..094b831
--- /dev/null
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class REST::CredentialAccountSerializer < REST::AccountSerializer
+  attributes :source
+
+  def source
+    user = object.user
+    {
+      privacy: user.setting_default_privacy,
+      note: object.note,
+    }
+  end
+end