Class: Decidim::BulletinBoard::Command
- Inherits:
-
Object
- Object
- Decidim::BulletinBoard::Command
show all
- Includes:
- Wisper::Publisher
- Defined in:
- lib/decidim/bulletin_board/command.rb
Overview
The base class for all commands.
Direct Known Subclasses
Authority::CreateElection, Authority::EndVote, Authority::GetElectionResults, Authority::GetElectionStatus, Authority::PublishResults, Authority::ReportMissingTrustee, Authority::StartKeyCeremony, Authority::StartTally, Authority::StartVote, Test::ResetTestDatabase, Voter::CastVote, Voter::GetPendingMessageStatus, Voter::InPersonVote
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#graphql ⇒ Object
Returns the value of attribute graphql.
9
10
11
|
# File 'lib/decidim/bulletin_board/command.rb', line 9
def graphql
@graphql
end
|
#settings ⇒ Object
Returns the value of attribute settings.
9
10
11
|
# File 'lib/decidim/bulletin_board/command.rb', line 9
def settings
@settings
end
|
Instance Method Details
#build_message_id(unique_election_id, type_subtype, voter_id = nil) ⇒ Object
27
28
29
|
# File 'lib/decidim/bulletin_board/command.rb', line 27
def build_message_id(unique_election_id, type_subtype, voter_id = nil)
MessageIdentifier.format(unique_election_id, type_subtype, voter_id ? :voter : :authority, voter_id || settings.authority_slug)
end
|
#complete_message(message_id, message) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/decidim/bulletin_board/command.rb', line 20
def complete_message(message_id, message)
message.merge({
iat: Time.now.to_i,
message_id:
})
end
|
11
12
13
14
|
# File 'lib/decidim/bulletin_board/command.rb', line 11
def configure(settings, graphql)
@settings = settings
@graphql = graphql
end
|
#sign_message(message_id, message) ⇒ Object
16
17
18
|
# File 'lib/decidim/bulletin_board/command.rb', line 16
def sign_message(message_id, message)
JWT.encode(complete_message(message_id, message), settings.authority_private_key.keypair, "RS256")
end
|
#unique_election_id(election_id) ⇒ Object
31
32
33
|
# File 'lib/decidim/bulletin_board/command.rb', line 31
def unique_election_id(election_id)
MessageIdentifier.unique_election_id(settings.authority_slug, election_id)
end
|