This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
569b26c
commit 0ea9745
Showing
12 changed files
with
400 additions
and
58 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
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,44 @@ | ||
defmodule Helix.Software.Action.Flow.Virus do | ||
|
||
alias Helix.Event | ||
alias Helix.Network.Model.Tunnel | ||
alias Helix.Network.Query.Network, as: NetworkQuery | ||
alias Helix.Process.Model.Process | ||
alias Helix.Server.Model.Server | ||
alias Helix.Software.Model.File | ||
alias Helix.Software.Model.Virus | ||
|
||
alias Helix.Software.Process.Virus.Collect, as: VirusCollectProcess | ||
|
||
@internet_id NetworkQuery.internet().network_id | ||
|
||
@type viruses :: [{File.t, Server.t}] | ||
|
||
@spec start_collect( | ||
Server.t, viruses, Tunnel.bounce_id, Virus.payment_info, Event.relay) | ||
:: | ||
[Process.t] | ||
| no_return | ||
def start_collect(gateway, viruses, bounce_id, {bank_acc, wallet}, relay) do | ||
Enum.reduce(viruses, [], fn {virus, target}, acc -> | ||
|
||
params = | ||
%{ | ||
wallet: wallet, | ||
bank_account: bank_acc | ||
} | ||
|
||
meta = | ||
%{ | ||
virus: virus, | ||
network_id: @internet_id, | ||
bounce: bounce_id | ||
} | ||
|
||
{:ok, process} = | ||
VirusCollectProcess.execute(gateway, target, params, meta, relay) | ||
|
||
acc ++ [process] | ||
end) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule Helix.Software.Event.Virus.Collect do | ||
|
||
import Helix.Event | ||
|
||
event Processed do | ||
|
||
alias Helix.Process.Model.Process | ||
alias Helix.Universe.Bank.Model.BankAccount | ||
alias Helix.Universe.Bank.Query.Bank, as: BankQuery | ||
alias Helix.Software.Model.File | ||
alias Helix.Software.Query.File, as: FileQuery | ||
|
||
alias Helix.Software.Process.Virus.Collect, as: VirusCollectProcess | ||
|
||
event_struct [:file, :bank_account, :wallet] | ||
|
||
@type t :: | ||
%__MODULE__{ | ||
file: File.t, | ||
bank_account: BankAccount.t | nil, | ||
wallet: term | nil | ||
} | ||
|
||
def new(process = %Process{}, %VirusCollectProcess{wallet: nil}) do | ||
bank_account = | ||
BankQuery.fetch_account(process.src_atm_id, process.src_acc_number) | ||
|
||
do_new(process, bank_account, nil) | ||
end | ||
|
||
def new(process = %Process{}, %VirusCollectProcess{wallet: wallet}), | ||
do: do_new(process, nil, wallet) | ||
|
||
defp do_new(process, bank_account, wallet) do | ||
%__MODULE__{ | ||
file: FileQuery.fetch(process.src_file_id), | ||
bank_account: bank_account, | ||
wallet: wallet | ||
} | ||
end | ||
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.