-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2116 from brave-intl/staging
Release 2019-08-07
- Loading branch information
Showing
44 changed files
with
571 additions
and
188 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -159,3 +159,14 @@ | |
} | ||
} | ||
} | ||
|
||
.not-verified { | ||
color: $braveGray-6; | ||
|
||
img { | ||
filter: grayscale(100%); | ||
} | ||
a { | ||
color: $braveGray-6; | ||
} | ||
} |
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,70 @@ | ||
class CreateUpholdChannelCardJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(uphold_connection_id:, channel_id:) | ||
uphold_connection = UpholdConnection.find(uphold_connection_id) | ||
channel = Channel.find(channel_id) | ||
return unless uphold_connection&.is_member? && channel&.verified? | ||
|
||
unless uphold_connection.can_create_uphold_cards? | ||
Rails.logger.info("Could not create uphold card for channel #{uphold_connection.publisher_id}. Uphold Verified: #{uphold_connection.uphold_verified}") | ||
return | ||
end | ||
|
||
upfc = UpholdConnectionForChannel.find_by( | ||
uphold_connection: uphold_connection, | ||
currency: uphold_connection.default_currency, | ||
channel_identifier: channel.details.channel_identifier | ||
) | ||
|
||
if upfc.present? | ||
card_id = upfc.card_id | ||
else | ||
(card_id, upfc) = create_card(uphold_connection, channel) | ||
end | ||
|
||
# If the channel was deleted and then recreated we should update this to be the new channel id | ||
upfc.update( | ||
address: get_address(uphold_connection, card_id), | ||
channel_id: channel.id | ||
) | ||
end | ||
|
||
def create_card(uphold_connection, channel) | ||
card_label = "#{channel.type_display} - #{channel.details.publication_title} - Brave Rewards" | ||
|
||
# If the card doesn't exist so we should create it | ||
card_id = uphold_connection.uphold_client.card.create( | ||
uphold_connection: uphold_connection, | ||
currency: uphold_connection.default_currency, | ||
label: card_label | ||
).id | ||
|
||
upfc = UpholdConnectionForChannel.create( | ||
uphold_connection: uphold_connection, | ||
channel: channel, | ||
card_id: card_id, | ||
currency: uphold_connection.default_currency, | ||
channel_identifier: channel.details.channel_identifier | ||
) | ||
|
||
[card_id, upfc] | ||
end | ||
|
||
def get_address(uphold_connection, card_id) | ||
addresses = uphold_connection.uphold_client.address.all( | ||
uphold_connection: uphold_connection, | ||
id: card_id | ||
) | ||
address = addresses.detect { |a| a.type == UpholdConnectionForChannel::NETWORK } | ||
address = address.formats.first.dig('value') if address.present? | ||
|
||
return address if address.present? | ||
|
||
uphold_connection.uphold_client.address.create( | ||
uphold_connection: uphold_connection, | ||
id: card_id, | ||
network: UpholdConnectionForChannel::NETWORK | ||
) | ||
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
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
# Creates a connection between uphold and a channel | ||
# | ||
# We use this to look up existing cards. If a user deletes a channel then we should not destroy this. | ||
# Really the only time we should delete is if the uphold connection gets deleted, which should only happen if the publisher | ||
class UpholdConnectionForChannel < ApplicationRecord | ||
belongs_to :uphold_connection | ||
belongs_to :channel | ||
|
||
NETWORK = 'anonymous' | ||
|
||
validates :channel_identifier, uniqueness: { scope: [:uphold_connection_id, :channel_identifier, :currency] } | ||
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
Oops, something went wrong.