forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
squashed identity proof updates (mastodon#10375)
- Loading branch information
1 parent
832d2ad
commit 86afc4c
Showing
20 changed files
with
214 additions
and
25 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
app/controllers/api/v1/accounts/identity_proofs_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::Accounts::IdentityProofsController < Api::BaseController | ||
before_action :require_user! | ||
before_action :set_account | ||
|
||
respond_to :json | ||
|
||
def index | ||
@proofs = @account.identity_proofs.active | ||
render json: @proofs, each_serializer: REST::IdentityProofSerializer | ||
end | ||
|
||
private | ||
|
||
def set_account | ||
@account = Account.find(params[:account_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import api from '../api'; | ||
|
||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST = 'IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST'; | ||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS = 'IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS'; | ||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL = 'IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL'; | ||
|
||
export const fetchAccountIdentityProofs = accountId => (dispatch, getState) => { | ||
dispatch(fetchAccountIdentityProofsRequest(accountId)); | ||
|
||
api(getState).get(`/api/v1/accounts/${accountId}/identity_proofs`) | ||
.then(({ data }) => dispatch(fetchAccountIdentityProofsSuccess(accountId, data))) | ||
.catch(err => dispatch(fetchAccountIdentityProofsFail(accountId, err))); | ||
}; | ||
|
||
export const fetchAccountIdentityProofsRequest = id => ({ | ||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST, | ||
id, | ||
}); | ||
|
||
export const fetchAccountIdentityProofsSuccess = (accountId, identity_proofs) => ({ | ||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS, | ||
accountId, | ||
identity_proofs, | ||
}); | ||
|
||
export const fetchAccountIdentityProofsFail = (accountId, err) => ({ | ||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, | ||
accountId, | ||
err, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Map as ImmutableMap, fromJS } from 'immutable'; | ||
import { | ||
IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST, | ||
IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS, | ||
IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, | ||
} from '../actions/identity_proofs'; | ||
|
||
const initialState = ImmutableMap(); | ||
|
||
export default function identityProofsReducer(state = initialState, action) { | ||
switch(action.type) { | ||
case IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST: | ||
return state.set('isLoading', true); | ||
case IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL: | ||
return state.set('isLoading', false); | ||
case IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS: | ||
return state.update(identity_proofs => identity_proofs.withMutations(map => { | ||
map.set('isLoading', false); | ||
map.set('loaded', true); | ||
map.set(action.accountId, fromJS(action.identity_proofs)); | ||
})); | ||
default: | ||
return state; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class REST::IdentityProofSerializer < ActiveModel::Serializer | ||
attributes :provider, :provider_username, :updated_at, :proof_url, :profile_url | ||
|
||
def proof_url | ||
object.badge.proof_url | ||
end | ||
|
||
def profile_url | ||
object.badge.profile_url | ||
end | ||
|
||
def provider | ||
object.provider.capitalize | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.