The code powering m.abunchtell.com https://m.abunchtell.com
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config_serializer.rb 1.5 KiB

Add Keybase integration (#10297) * create account_identity_proofs table * add endpoint for keybase to check local proofs * add async task to update validity and liveness of proofs from keybase * first pass keybase proof CRUD * second pass keybase proof creation * clean up proof list and add badges * add avatar url to keybase api * Always highlight the “Identity Proofs” navigation item when interacting with proofs. * Update translations. * Add profile URL. * Reorder proofs. * Add proofs to bio. * Update settings/identity_proofs front-end. * Use `link_to`. * Only encode query params if they exist. URLs without params had a trailing `?`. * Only show live proofs. * change valid to active in proof list and update liveness before displaying * minor fixes * add keybase config at well-known path * extremely naive feature flagging off the identity proof UI * fixes for rubocop * make identity proofs page resilient to potential keybase issues * normalize i18n * tweaks for brakeman * remove two unused translations * cleanup and add more localizations * make keybase_contacts an admin setting * fix ExternalProofService my_domain * use Addressable::URI in identity proofs * use active model serializer for keybase proof config * more cleanup of keybase proof config * rename proof is_valid and is_live to proof_valid and proof_live * cleanup * assorted tweaks for more robust communication with keybase * Clean up * Small fixes * Display verified identity identically to verified links * Clean up unused CSS * Add caching for Keybase avatar URLs * Remove keybase_contacts setting
5 년 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # frozen_string_literal: true
  2. class ProofProvider::Keybase::ConfigSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :version, :domain, :display_name, :username,
  5. :brand_color, :logo, :description, :prefill_url,
  6. :profile_url, :check_url, :check_path, :avatar_path,
  7. :contact
  8. def version
  9. 1
  10. end
  11. def domain
  12. Rails.configuration.x.local_domain
  13. end
  14. def display_name
  15. Setting.site_title
  16. end
  17. def logo
  18. { svg_black: full_asset_url(asset_pack_path('media/images/logo_transparent_black.svg')), svg_full: full_asset_url(asset_pack_path('media/images/logo.svg')) }
  19. end
  20. def brand_color
  21. '#282c37'
  22. end
  23. def description
  24. Setting.site_short_description.presence || Setting.site_description.presence || I18n.t('about.about_mastodon_html')
  25. end
  26. def username
  27. { min: 1, max: 30, re: Account::USERNAME_RE.inspect }
  28. end
  29. def prefill_url
  30. params = {
  31. provider: 'keybase',
  32. token: '%{sig_hash}',
  33. provider_username: '%{kb_username}',
  34. username: '%{username}',
  35. user_agent: '%{kb_ua}',
  36. }
  37. CGI.unescape(new_settings_identity_proof_url(params))
  38. end
  39. def profile_url
  40. CGI.unescape(short_account_url('%{username}')) # rubocop:disable Style/FormatStringToken
  41. end
  42. def check_url
  43. CGI.unescape(api_proofs_url(username: '%{username}', provider: 'keybase'))
  44. end
  45. def check_path
  46. ['signatures']
  47. end
  48. def avatar_path
  49. ['avatar']
  50. end
  51. def contact
  52. [Setting.site_contact_email.presence].compact
  53. end
  54. end