mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix merge conflict
This commit is contained in:
commit
fdb46d5545
@ -39,33 +39,144 @@ class StateBalancesController extends AppController
|
||||
$this->set(compact('stateBalances'));
|
||||
}
|
||||
|
||||
private function updateBalances($state_user_id)
|
||||
private function updateBalances($stateUserId)
|
||||
{
|
||||
$state_balances = $this->StateBalances->find('all')->where(['state_user_id' => $state_user_id]);
|
||||
if($state_balances->count() == 1) {
|
||||
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
|
||||
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
|
||||
// info: cakephp use lazy loading, query will be executed later only if needed
|
||||
$state_balances = $this->StateBalances->find('all')->where(['state_user_id' => $stateUserId]);
|
||||
$state_user_transactions = $stateUserTransactionsTable
|
||||
->find('all')
|
||||
->where(['state_user_id' => $state_user_id])
|
||||
->where(['state_user_id' => $stateUserId])
|
||||
->order(['transaction_id ASC'])
|
||||
->contain(['']);
|
||||
if($state_user_transactions->count() == 0){
|
||||
return;
|
||||
->contain(false);
|
||||
|
||||
if(!$state_user_transactions) {
|
||||
//debug($state_user_transactions);
|
||||
return true;
|
||||
}
|
||||
|
||||
// first: decide what todo
|
||||
$create_state_balance = false;
|
||||
$recalculate_state_user_transactions_balance = false;
|
||||
$clear_state_balance = false;
|
||||
$update_state_balance = false;
|
||||
if($state_balances->count() == 0) {
|
||||
$create_state_balance = true;
|
||||
}
|
||||
if($state_balances->count() > 1) {
|
||||
$clear_state_balance = true;
|
||||
$create_state_balance = true;
|
||||
}
|
||||
if($state_balances->count() == 1) {
|
||||
if($state_user_transactions->count() == 0){
|
||||
$clear_state_balance = true;
|
||||
} else {
|
||||
$last_state_user_transaction = $state_user_transactions->last();
|
||||
$last_transaction = $this->StateBalance->newEntity();
|
||||
$last_transaction = $this->StateBalances->newEntity();
|
||||
$last_transaction->amount = $last_state_user_transaction->balance;
|
||||
$last_transaction->record_date = $last_state_user_transaction->balance_date;
|
||||
// if entrys are nearly the same, we don't need doing anything
|
||||
if(abs($last_transaction->decay - $state_balances->decay) < 100) {
|
||||
return;
|
||||
if(abs($last_transaction->decay - $state_balances->first()->decay) > 100) {
|
||||
$recalculate_state_user_transactions_balance = true;
|
||||
$update_state_balance = true;
|
||||
}
|
||||
}
|
||||
foreach($state_user_transactions as $state_user_transaction) {
|
||||
|
||||
}
|
||||
|
||||
if(!$recalculate_state_user_transactions_balance) {
|
||||
$last_state_user_transaction = $state_user_transactions->last();
|
||||
if($last_state_user_transaction->balance <= 0) {
|
||||
$recalculate_state_user_transactions_balance = true;
|
||||
if(!$create_state_balance) {
|
||||
$update_state_balance = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// second: do what is needed
|
||||
if($clear_state_balance) {
|
||||
$this->StateBalances->deleteAll(['state_user_id' => $stateUserId]);
|
||||
}
|
||||
|
||||
$transaction_ids = [];
|
||||
if($recalculate_state_user_transactions_balance) {
|
||||
$state_user_transactions_array = $state_user_transactions->toArray();
|
||||
foreach($state_user_transactions_array as $i => $state_user_transaction) {
|
||||
$transaction_ids[$state_user_transaction->transaction_id] = $i;
|
||||
}
|
||||
|
||||
$transactions = $transactionsTable
|
||||
->find('all')
|
||||
->where(['id IN' => array_keys($transaction_ids)])
|
||||
->contain(['TransactionCreations', 'TransactionSendCoins']);
|
||||
|
||||
$balance_cursor = $this->StateBalances->newEntity();
|
||||
$i = 0;
|
||||
foreach($transactions as $transaction) {
|
||||
if($transaction->transaction_type_id > 2) {
|
||||
continue;
|
||||
}
|
||||
$amount_date = null;
|
||||
$amount = 0;
|
||||
|
||||
if($transaction->transaction_type_id == 1) {
|
||||
$temp = $transaction->transaction_creations[0];
|
||||
|
||||
$balance_temp = $this->StateBalances->newEntity();
|
||||
$balance_temp->amount = $temp->amount;
|
||||
$balance_temp->record_date = $temp->target_date;
|
||||
|
||||
$amount = $balance_temp->partDecay($transaction->received);
|
||||
$amount_date = $transaction->received;
|
||||
//$amount_date =
|
||||
} else if($transaction->transaction_type_id == 2) {
|
||||
$temp = $transaction->transaction_send_coins[0];
|
||||
$amount = intval($temp->amount);
|
||||
// reverse if sender
|
||||
if($stateUserId == $temp->state_user_id) {
|
||||
$amount *= -1.0;
|
||||
}
|
||||
$amount_date = $transaction->received;
|
||||
}
|
||||
if($i == 0) {
|
||||
$balance_cursor->amount = $amount;
|
||||
} else {
|
||||
$balance_cursor->amount = $balance_cursor->partDecay($amount_date) + $amount;
|
||||
}
|
||||
$balance_cursor->record_date = $amount_date;
|
||||
$state_user_transaction_index = $transaction_ids[$transaction->id];
|
||||
$state_user_transactions_array[$state_user_transaction_index]->balance = $balance_cursor->amount;
|
||||
$state_user_transactions_array[$state_user_transaction_index]->balance_date = $balance_cursor->record_date;
|
||||
$i++;
|
||||
}
|
||||
$results = $stateUserTransactionsTable->saveMany($state_user_transactions_array);
|
||||
$errors = [];
|
||||
foreach($results as $i => $result) {
|
||||
if(!$result) {
|
||||
$errors[$i] = $state_user_transactions_array[$i]->getErrors();
|
||||
}
|
||||
}
|
||||
if(count($errors)) {
|
||||
return ['success' => false, 'error' => 'error saving one ore more state user transactions', 'details' => $errors];
|
||||
}
|
||||
}
|
||||
$state_balance = null;
|
||||
if($update_state_balance) {
|
||||
$state_balance = $state_balances->first();
|
||||
}
|
||||
else if($create_state_balance) {
|
||||
$state_balance = $this->StateBalances->newEntity();
|
||||
$state_balance->state_user_id = $stateUserId;
|
||||
}
|
||||
if($state_balance) {
|
||||
$state_balance->amount = $state_user_transactions->last()->balance;
|
||||
$state_balance->record_date = $state_user_transactions->last()->balance_date;
|
||||
if(!$this->StateBalances->save($state_balance)) {
|
||||
return ['success' => false, 'error' => 'error saving state balance', 'details' => $state_balance->getErrors()];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function overview()
|
||||
{
|
||||
@ -82,7 +193,9 @@ class StateBalancesController extends AppController
|
||||
if ($result !== true) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$user = $session->read('StateUser');
|
||||
$this->updateBalances($user['id']);
|
||||
// sendRequestGDT
|
||||
// listPerEmailApi
|
||||
|
||||
@ -214,6 +327,7 @@ class StateBalancesController extends AppController
|
||||
}
|
||||
$session = $this->getRequest()->getSession();
|
||||
$user = $session->read('StateUser');
|
||||
$this->updateBalances($user['id']);
|
||||
|
||||
$public_key_bin = hex2bin($user['public_hex']);
|
||||
$stateUserQuery = $this->StateBalances->StateUsers
|
||||
|
||||
@ -69,14 +69,14 @@ class StateUsersController extends AppController
|
||||
$this->set(compact('stateUsers'));
|
||||
}
|
||||
|
||||
public function listIdentHashes()
|
||||
/*public function listIdentHashes()
|
||||
{
|
||||
$stateUsers = $this->StateUsers->find('all')->toArray();
|
||||
foreach ($stateUsers as $i => $user) {
|
||||
$stateUsers[$i]->identHash = TransactionCreation::DRMakeStringHash($user->email);
|
||||
}
|
||||
$this->set('stateUsers', $stateUsers);
|
||||
}
|
||||
}*/
|
||||
|
||||
public function search()
|
||||
{
|
||||
|
||||
@ -54,12 +54,12 @@ class TransactionCreationsController extends AppController
|
||||
];
|
||||
$transactionCreations = $this->paginate($this->TransactionCreations);
|
||||
$identHashes = [];
|
||||
foreach ($transactionCreations as $creation) {
|
||||
/*foreach ($transactionCreations as $creation) {
|
||||
$identHash = TransactionCreation::DRMakeStringHash($creation->state_user->email);
|
||||
$identHashes[$creation->state_user->id] = $identHash;
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->set(compact('transactionCreations', 'identHashes'));
|
||||
//$this->set(compact('transactionCreations', 'identHashes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ class TransactionCreationsController extends AppController
|
||||
|
||||
if (count($receiverProposal) > $receiverIndex) {
|
||||
$pubKeyHex = $receiverProposal[$receiverIndex]['key'];
|
||||
$identHash = TransactionCreation::DRMakeStringHash($receiverProposal[$receiverIndex]['email']);
|
||||
//$identHash = TransactionCreation::DRMakeStringHash($receiverProposal[$receiverIndex]['email']);
|
||||
}
|
||||
$builderResult = TransactionCreation::build(
|
||||
$amountCent,
|
||||
@ -369,7 +369,20 @@ class TransactionCreationsController extends AppController
|
||||
$pendings[$id] = $localAmountCent;
|
||||
}
|
||||
$pubKeyHex = bin2hex(stream_get_contents($receiverUser->public_key));
|
||||
$identHash = TransactionCreation::DRMakeStringHash($receiverUser->email);
|
||||
$requestAnswear = $this->JsonRequestClient->sendRequest(json_encode([
|
||||
'session_id' => $session->read('session_id'),
|
||||
'email' => $receiverUser->email,
|
||||
'ask' => ['user.identHash']
|
||||
]), '/getUserInfos');
|
||||
|
||||
$identHash = 0;
|
||||
if('success' == $requestAnswear['state'] && 'success' == $requestAnswear['data']['state']) {
|
||||
$identHash = $requestAnswear['data']['userData']['identHash'];
|
||||
} else {
|
||||
$this->Flash->error(__('Error by requesting LoginServer, please try again'));
|
||||
}
|
||||
|
||||
//$identHash = TransactionCreation::DRMakeStringHash($receiverUser->email);
|
||||
$localTargetDateFrozen = FrozenDate::now();
|
||||
$localTargetDateFrozen = $localTargetDateFrozen
|
||||
->year($localTargetDate['year'])
|
||||
|
||||
@ -57,7 +57,8 @@ class StateBalance extends Entity
|
||||
if($decay_duration === 0) {
|
||||
return $this->amount;
|
||||
}
|
||||
return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
return $this->amount;
|
||||
//return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
|
||||
}
|
||||
public function partDecay($target_date)
|
||||
@ -67,7 +68,8 @@ class StateBalance extends Entity
|
||||
if($decay_duration <= 0) {
|
||||
return $this->amount;
|
||||
}
|
||||
return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
return $this->amount;
|
||||
//return $this->amount * pow(0.99999997802044727, $decay_duration);
|
||||
}
|
||||
|
||||
public function decayDuration($target_date)
|
||||
|
||||
@ -63,24 +63,6 @@ class TransactionCreation extends TransactionBase {
|
||||
return ['state' => 'success', 'transactionBody' => $transactionBody];
|
||||
}
|
||||
|
||||
static protected function DRHashRotateLeft( $hash, $rotateBy )
|
||||
{
|
||||
return ($hash<<$rotateBy)|($hash>>(32-$rotateBy));
|
||||
}
|
||||
|
||||
static public function DRMakeStringHash($str)
|
||||
{
|
||||
$ret = 0;
|
||||
|
||||
if( $str )
|
||||
{
|
||||
for ($i=0; $i < strlen($str); $i++)
|
||||
{
|
||||
// $ret = TransactionCreation::DRHashRotateLeft($ret, 7) + ord($str{$i});
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getAmount() {
|
||||
return $this->protoTransactionCreation->getReceiverAmount()->getAmount();
|
||||
@ -303,7 +285,7 @@ class TransactionCreation extends TransactionBase {
|
||||
|
||||
// intval
|
||||
//$protoCreation->setIdentHash(intval($identHashBytes));
|
||||
$protoCreation->setIdentHash(self::DRMakeStringHash($stateUser->email));
|
||||
//$protoCreation->setIdentHash(self::DRMakeStringHash($stateUser->email));
|
||||
return new TransactionCreation($protoCreation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,8 @@ class TransactionTransfer extends TransactionBase {
|
||||
foreach($sigPairs as $sigPair) {
|
||||
//echo 'sig Pair: '; var_dump($sigPair); echo "<br>";
|
||||
$pubkey = bin2hex($sigPair->getPubKey());
|
||||
$hash = TransactionCreation::DRMakeStringHash($pubkey);
|
||||
//$hash = TransactionCreation::DRMakeStringHash($pubkey);
|
||||
$hash = $pubkey;
|
||||
if(!isset($sigPubHexs[$hash])) {
|
||||
$sigPubHexs[$hash] = [$pubkey];
|
||||
} else {
|
||||
@ -100,7 +101,8 @@ class TransactionTransfer extends TransactionBase {
|
||||
return false;
|
||||
}
|
||||
// check if signature exist for sender
|
||||
$hash = TransactionCreation::DRMakeStringHash($senderPublicHex);
|
||||
//$hash = TransactionCreation::DRMakeStringHash($senderPublicHex);
|
||||
$hash = $senderPublicHex;
|
||||
if(!isset($sigPubHexs[$hash]) || in_array($senderPublicHex, $sigPubHexs[$hash]) === FALSE) {
|
||||
$this->addError($functionName, 'missing signature for sender');
|
||||
return false;
|
||||
|
||||
@ -62,6 +62,20 @@ services:
|
||||
volumes:
|
||||
- /sessions
|
||||
|
||||
#########################################################
|
||||
## skeema for updating dbs if changes happend ###########
|
||||
#########################################################
|
||||
skeema:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./skeema/Dockerfile
|
||||
target: skeema_run
|
||||
container_name: skeema
|
||||
depends_on:
|
||||
- mariadb
|
||||
networks:
|
||||
- internal-net
|
||||
|
||||
volumes:
|
||||
frontend_node_modules:
|
||||
conan:
|
||||
@ -39,7 +39,12 @@ export default {
|
||||
//console.log('%cHey %c' + $cookies.get('gdd_u') + '', 'font-weight:bold', 'color: orange')
|
||||
this.$store.commit('session_id', $cookies.get('gdd_session_id'))
|
||||
this.$store.commit('email', $cookies.get('gdd_u'))
|
||||
if ($cookies.get('gdd_lang') != 'de' || $cookies.get('gdd_lang') != 'de') {
|
||||
this.$store.commit('language', 'de')
|
||||
} else {
|
||||
this.$store.commit('language', $cookies.get('gdd_lang'))
|
||||
}
|
||||
|
||||
this.$i18n.locale = $cookies.get('gdd_lang')
|
||||
this.$router.push('overview')
|
||||
} else {
|
||||
|
||||
@ -1,210 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-row>
|
||||
<b-col xl="12" md="12">
|
||||
<base-button icon type="info" size="lg" v-b-toggle.collapse-2>
|
||||
<span class="btn-inner--icon"><i class="ni ni-fat-add"></i></span>
|
||||
<span class="btn-inner--text">
|
||||
{{ $t('site.overview.add_work') }}
|
||||
</span>
|
||||
</base-button>
|
||||
<b-collapse id="collapse-2" class="mt-2">
|
||||
<b-card>
|
||||
<div class="card-text">
|
||||
<b-row>
|
||||
<b-col>
|
||||
<h1>Neuer Beitrag</h1>
|
||||
<h3>{ Name der Community }</h3>
|
||||
</b-col>
|
||||
<b-col>
|
||||
<h3>Bitte trage jede arbeit einzeln ein.</h3>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<hr />
|
||||
<b-form @submit="onSubmit" @reset="onReset" v-if="show">
|
||||
<b-row class="form-group">
|
||||
<label
|
||||
for="example-datetime-local-input"
|
||||
class="col-md-2 col-form-label form-control-label form-control-lg"
|
||||
>
|
||||
von
|
||||
</label>
|
||||
<b-col md="10">
|
||||
<base-input
|
||||
type="datetime-local"
|
||||
value="2018-11-23T10:30:00"
|
||||
v-model="form.from"
|
||||
@change="dateDiff"
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row class="form-group">
|
||||
<label
|
||||
for="example-datetime-local-input"
|
||||
class="col-md-2 col-form-label form-control-label form-control-lg"
|
||||
>
|
||||
bis
|
||||
</label>
|
||||
<b-col md="10">
|
||||
<base-input
|
||||
type="datetime-local"
|
||||
value="2018-11-23T10:30:00"
|
||||
v-model="form.to"
|
||||
@change="dateDiff"
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row class="form-group">
|
||||
<label
|
||||
for="example-datetime-local-input"
|
||||
class="col-md-2 col-form-label form-control-label form-control-lg"
|
||||
>
|
||||
Stunden
|
||||
</label>
|
||||
<b-col md="10">
|
||||
<base-input type="text" v-model="form.hours" disabled class="form-control-lg" />
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row class="form-group">
|
||||
<label
|
||||
for="example-datetime-local-input"
|
||||
class="col-md-2 col-form-label form-control-label form-control-lg"
|
||||
>
|
||||
GDD Shöpfen
|
||||
</label>
|
||||
<b-col md="10">
|
||||
<base-input
|
||||
type="text"
|
||||
:value="form.hours * 20"
|
||||
disabled
|
||||
class="form-control-lg"
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row class="form-group">
|
||||
<label class="col-md-2 col-form-label form-control-label form-control-lg">
|
||||
Ort
|
||||
</label>
|
||||
<b-col md="10">
|
||||
<base-input
|
||||
placeholder="Berlin"
|
||||
v-model="form.location"
|
||||
class="form-control-lg"
|
||||
></base-input>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row class="form-group">
|
||||
<label class="col-md-2 col-form-label form-control-label form-control-lg">
|
||||
Kategorie
|
||||
</label>
|
||||
<b-col md="10">
|
||||
<base-input>
|
||||
<select class="form-control form-control-lg">
|
||||
<option>Umwelt</option>
|
||||
<option>Helfen</option>
|
||||
<option>Verein</option>
|
||||
</select>
|
||||
</base-input>
|
||||
</b-col>
|
||||
</b-row>
|
||||
|
||||
<base-input label="Beitrag">
|
||||
<textarea
|
||||
class="form-control form-control-lg"
|
||||
rows="3"
|
||||
v-model="form.text"
|
||||
></textarea>
|
||||
</base-input>
|
||||
<b-row class="form-group">
|
||||
<label class="col-md-2 col-form-label form-control-label form-control-lg">
|
||||
Tätigkeit
|
||||
</label>
|
||||
<b-col md="8">
|
||||
<base-input
|
||||
placeholder="Tätigkeit"
|
||||
v-model="form.location"
|
||||
class="form-control-lg"
|
||||
></base-input>
|
||||
</b-col>
|
||||
<b-col md="2">
|
||||
<base-input
|
||||
placeholder="Stunden"
|
||||
v-model="form.location"
|
||||
class="form-control-lg"
|
||||
></base-input>
|
||||
</b-col>
|
||||
</b-row>
|
||||
|
||||
<br />
|
||||
|
||||
<br />
|
||||
<b-button type="submit" variant="success">
|
||||
jetzt einreichen
|
||||
<small>{{ timestamp }}</small>
|
||||
</b-button>
|
||||
<b-button type="reset" variant="danger">Cancel</b-button>
|
||||
<br />
|
||||
</b-form>
|
||||
</div>
|
||||
</b-card>
|
||||
</b-collapse>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'GDDAddWork',
|
||||
data() {
|
||||
return {
|
||||
show: true,
|
||||
form: {
|
||||
from: '',
|
||||
to: '',
|
||||
hours: '',
|
||||
text: '',
|
||||
gdd: 0.0,
|
||||
location: '',
|
||||
text2: '',
|
||||
sendtime: '',
|
||||
},
|
||||
timestamp: '',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
setInterval(this.getNow, 2000)
|
||||
},
|
||||
methods: {
|
||||
dateDiff() {
|
||||
this.form.hours = (this.$moment(this.form.to) - this.$moment(this.form.from)) / 1000 / 3600
|
||||
},
|
||||
getNow: function () {
|
||||
//const today = new Date()
|
||||
//const date = today.getDate()+'.'+(today.getMonth()+1)+'.'+ today.getFullYear();
|
||||
//const time = today.getHours() + ":" + today.getMinutes();
|
||||
//const dateTime = date +', '+ time;
|
||||
this.timestamp = new Date()
|
||||
},
|
||||
onSubmit(event) {
|
||||
event.preventDefault()
|
||||
//console.log('onSUBMIT this.form.from >>>>', this.form.from)
|
||||
//console.log('onSUBMIT this.form.from >>>>', this.$moment(this.form.from))
|
||||
//console.log('onSUBMIT this.form.to >>>>', this.form.to)
|
||||
// console.log("onSUBMIT >>>>", this.getHours(this.form.from, this.form.to))
|
||||
this.form.sendtime = new Date()
|
||||
alert(JSON.stringify(this.form))
|
||||
},
|
||||
onReset(event) {
|
||||
event.preventDefault()
|
||||
// Reset our form values
|
||||
|
||||
// Trick to reset/clear native browser form validation state
|
||||
this.show = false
|
||||
this.$nextTick(() => {
|
||||
this.show = true
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -17,7 +17,7 @@
|
||||
class="form-control"
|
||||
v-model="date"
|
||||
:config="config"
|
||||
style="font-size: xx-large; padding-left: 20px"
|
||||
style="font-size: x-large; padding-left: 20px"
|
||||
></flat-pickr>
|
||||
</base-input>
|
||||
</b-col>
|
||||
@ -45,83 +45,9 @@
|
||||
</b-row>
|
||||
</b-tab>
|
||||
|
||||
<b-tab :title="names.lastMonth">
|
||||
<b-row>
|
||||
<b-col cols="3">
|
||||
<base-input label="Arbeitstunden">
|
||||
<b-form-input type="number" placeholder="23" />
|
||||
</base-input>
|
||||
<base-input label="Datum / Zeitraum">
|
||||
<flat-pickr class="form-control" v-model="date" :config="lastConfig"></flat-pickr>
|
||||
</base-input>
|
||||
</b-col>
|
||||
<b-col cols="9">
|
||||
<base-input label="Arbeitsreport">
|
||||
<textarea class="form-control" rows="5" @focus="textFocus"></textarea>
|
||||
</base-input>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col md="12">
|
||||
<b-button @click.prevent="newWorkForm" variant="warning">
|
||||
+ weiteren Report hinzufügen
|
||||
</b-button>
|
||||
</b-col>
|
||||
<b-col md="12" class="text-right">
|
||||
<b-button variant="success">Einreichen, absenden</b-button>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<hr />
|
||||
<pre>Selected date is - {{ date }}</pre>
|
||||
<p>{{ days.lastMonth }} Days in {{ names.lastMonth }}</p>
|
||||
<b-tab :title="names.lastMonth"></b-tab>
|
||||
|
||||
<p>
|
||||
Du hast diesen Monat
|
||||
{{ stundenSumme > 0 ? 'schon ' : 'noch keine' }}
|
||||
{{ stundenSumme > 0 ? '' + stundenSumme : '' }}
|
||||
Stunden eingetragen
|
||||
</p>
|
||||
</b-tab>
|
||||
|
||||
<b-tab :title="names.beforLastMonth">
|
||||
<b-row>
|
||||
<b-col cols="3">
|
||||
<base-input label="Arbeitstunden">
|
||||
<b-form-input type="number" placeholder="23" />
|
||||
</base-input>
|
||||
<base-input label="Datum / Zeitraum">
|
||||
<flat-pickr
|
||||
class="form-control"
|
||||
v-model="date"
|
||||
:config="beforLastConfig"
|
||||
></flat-pickr>
|
||||
</base-input>
|
||||
</b-col>
|
||||
<b-col cols="9">
|
||||
<base-input label="Arbeitsreport">
|
||||
<textarea class="form-control" rows="5" @focus="textFocus"></textarea>
|
||||
</base-input>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col>
|
||||
<button class="btn btn-warning text-right" @click.prevent="newWorkForm">
|
||||
+ weiteren Report hinzufügen
|
||||
</button>
|
||||
</b-col>
|
||||
<b-col>
|
||||
<div class="text-right">
|
||||
<button class="btn btn-info text-right" @click.prevent="submitForm3">
|
||||
save new Report
|
||||
</button>
|
||||
</div>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<hr />
|
||||
<pre>Selected date is - {{ date }}</pre>
|
||||
<p>{{ days.beforLastMonth }} Days in {{ names.beforLastMonth }}</p>
|
||||
<p>Du hast noch keine Einträge</p>
|
||||
</b-tab>
|
||||
<b-tab :title="names.beforLastMonth"></b-tab>
|
||||
</b-tabs>
|
||||
</div>
|
||||
</template>
|
||||
@ -143,32 +69,6 @@ export default {
|
||||
maxDate: this.$moment().format('DD.MM.YYYY'),
|
||||
mode: 'range',
|
||||
},
|
||||
lastConfig: {
|
||||
altInput: false,
|
||||
dateFormat: 'd-m-Y',
|
||||
minDate: this.$moment()
|
||||
.month(this.$moment().month() - 1)
|
||||
.startOf('month')
|
||||
.format('DD.MM.YYYY'),
|
||||
maxDate: this.$moment()
|
||||
.month(this.$moment().month() - 1)
|
||||
.endOf('month')
|
||||
.format('DD.MM.YYYY'),
|
||||
mode: 'range',
|
||||
},
|
||||
beforLastConfig: {
|
||||
altInput: false,
|
||||
dateFormat: 'd-m-Y',
|
||||
minDate: this.$moment()
|
||||
.month(this.$moment().month() - 2)
|
||||
.startOf('month')
|
||||
.format('DD.MM.YYYY'),
|
||||
maxDate: this.$moment()
|
||||
.month(this.$moment().month() - 2)
|
||||
.endOf('month')
|
||||
.format('DD.MM.YYYY'),
|
||||
mode: 'range',
|
||||
},
|
||||
index: 0,
|
||||
form: [],
|
||||
stundenSumme: 0,
|
||||
@ -192,7 +92,7 @@ export default {
|
||||
.month(this.$moment().month() - 2)
|
||||
.format('MMMM'),
|
||||
},
|
||||
formular: null
|
||||
formular: null,
|
||||
}
|
||||
},
|
||||
created() {},
|
||||
@ -201,24 +101,12 @@ export default {
|
||||
stunden(this.form)
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
getTR(m, i) {
|
||||
//console.log(m + '-' + i)
|
||||
},
|
||||
stunden(hour, i, mon) {
|
||||
let n = 0
|
||||
//console.log('stunden(form)=>', hour)
|
||||
//console.log('stunden(i)=>', i)
|
||||
//console.log('stunden(mon)=>', mon)
|
||||
|
||||
//console.log('this.stundenSumme start=> ', this.stundenSumme)
|
||||
this.stundenSumme = 0
|
||||
//console.log('arr.length => ', this.form.length)
|
||||
for (n; n < this.form.length; n++) {
|
||||
//console.log('>arr[n]=> ', this.form[n])
|
||||
if (this.form[n] > 0) {
|
||||
this.stundenSumme += parseInt(this.form[n])
|
||||
}
|
||||
@ -232,7 +120,6 @@ export default {
|
||||
TextDecoded: '',
|
||||
})
|
||||
this.index++
|
||||
//console.log('this.stundenSumme ende=> ', this.stundenSumme)
|
||||
},
|
||||
addNewMessage: function () {
|
||||
this.messages.push({
|
||||
@ -241,24 +128,15 @@ export default {
|
||||
})
|
||||
},
|
||||
deleteNewMessage: function (event) {
|
||||
//console.log('deleteNewMessage:event) => ', event)
|
||||
//console.log("deleteNewMessage:this.events.splice(this.event) => ", this.events.splice(this.event))
|
||||
this.form.splice(event, null)
|
||||
this.messages.splice(index, 1)
|
||||
this.index--
|
||||
},
|
||||
submitForm: function (e) {
|
||||
//console.log(this.messages)
|
||||
|
||||
//console.log('submitForm')
|
||||
this.messages = [{ DaysNumber: '', TextDecoded: '' }]
|
||||
this.submitted = true
|
||||
},
|
||||
submitForm2() {
|
||||
//console.log('submitForm2 TODO')
|
||||
},
|
||||
submitForm3() {
|
||||
//console.log('submitForm3 TODO')
|
||||
},
|
||||
textFocus() {
|
||||
//console.log('textFocus TODO')
|
||||
},
|
||||
@ -294,14 +172,12 @@ export default {
|
||||
</b-col>
|
||||
`
|
||||
|
||||
|
||||
console.log('newWorkForm TODO')
|
||||
// console.log('newWorkForm TODO')
|
||||
const myElement = this.$refs.mydiv
|
||||
myElement.append(this.formular);
|
||||
this.$compile(myElement);
|
||||
myElement.append(this.formular)
|
||||
this.$compile(myElement)
|
||||
this.formular = null
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
Bitte überprüfe alle deine Eingaben sehr genau. Du bist alleine Verantwortlich für deine
|
||||
Entscheidungen. Versendete Gradidos können nicht wieder zurück geholt werden.
|
||||
</b-alert>
|
||||
<b-card class="p-0 p-md-3">
|
||||
<b-card class="p-0 p-md-3" style="background-color: #ebebeba3 !important">
|
||||
<b-alert show variant="secondary">
|
||||
<span class="alert-text">
|
||||
<strong>QR Code Scanner</strong>
|
||||
@ -230,10 +230,9 @@ export default {
|
||||
const arr = JSON.parse(decodedString)
|
||||
//console.log('qr-email', arr[0].email)
|
||||
//console.log('qr-amount', arr[0].amount)
|
||||
|
||||
this.$store.state.row_form = false
|
||||
this.$store.state.row_check = true
|
||||
this.$store.state.row_thx = false
|
||||
this.form.email = arr[0].email
|
||||
this.form.amount = arr[0].amount
|
||||
this.scan = false
|
||||
},
|
||||
async onSubmit() {
|
||||
//event.preventDefault()
|
||||
|
||||
@ -2,12 +2,22 @@
|
||||
<div>
|
||||
<b-row v-show="$store.state.row_form">
|
||||
<b-col xl="6" md="6">
|
||||
<stats-card type="gradient-red" sub-title="balance_gdd" class="mb-4 h1">
|
||||
<stats-card
|
||||
type="gradient-red"
|
||||
sub-title="balance_gdd"
|
||||
class="mb-4 h1"
|
||||
style="background-color: #ebebeba3 !important"
|
||||
>
|
||||
{{ $n($store.state.user.balance) }} GDD
|
||||
</stats-card>
|
||||
</b-col>
|
||||
<b-col xl="6" md="6">
|
||||
<stats-card type="gradient-orange" sub-title="balance_gdt" class="mb-4 h1">
|
||||
<stats-card
|
||||
type="gradient-orange"
|
||||
sub-title="balance_gdt"
|
||||
class="mb-4 h1"
|
||||
style="background-color: #ebebeba3 !important"
|
||||
>
|
||||
{{ $n($store.state.user.balance_gdt) }} GDT
|
||||
</stats-card>
|
||||
</b-col>
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
<template>
|
||||
<card>
|
||||
<b-row align-v="center" slot="header">
|
||||
<b-col cols="8"></b-col>
|
||||
<b-col cols="4" class="text-right"></b-col>
|
||||
</b-row>
|
||||
|
||||
<card style="background-color: #ebebeba3 !important">
|
||||
<b-form @submit.prevent="updateProfile">
|
||||
<h6 class="heading-small text-muted mb-4">User information</h6>
|
||||
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<b-card no-body class="card-profile" alt="Image placeholder" img-top>
|
||||
<b-card
|
||||
no-body
|
||||
class="card-profile"
|
||||
alt="Image placeholder"
|
||||
img-top
|
||||
style="background-color: #ebebeba3 !important"
|
||||
>
|
||||
<b-row class="justify-content-center">
|
||||
<b-col lg="3" class="order-lg-2">
|
||||
<div class="card-profile-image">
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
//import GddTable from '../../views/KontoOverview/GddTable.vue'
|
||||
import GddWorkTable from '../../views/KontoOverview/GddWorkTable.vue'
|
||||
import GddAddWork2 from '../../views/KontoOverview/GddAddWork2.vue'
|
||||
|
||||
@ -40,7 +39,6 @@ import LineChart from '@/components/Charts/LineChart'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
// GddTable,
|
||||
GddWorkTable,
|
||||
LineChart,
|
||||
GddAddWork2,
|
||||
|
||||
@ -11,16 +11,15 @@ using namespace Poco::Data::Keywords;
|
||||
#include "../SingletonManager/ConnectionManager.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
#include "../SingletonManager/SessionManager.h"
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#include "../tasks/PrepareEmailTask.h"
|
||||
#include "../tasks/SendEmailTask.h"
|
||||
|
||||
#include "../controller/EmailVerificationCode.h"
|
||||
#include "../model/table/ElopageBuy.h"
|
||||
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
|
||||
|
||||
void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||
@ -277,22 +276,9 @@ int HandleElopageRequestTask::run()
|
||||
saveElopageBuy->scheduleTask(saveElopageBuy);
|
||||
|
||||
// check product id
|
||||
Poco::UInt64 product_id = 0;
|
||||
try {
|
||||
product_id = stoull(mRequestData.get("product[id]", "0"));
|
||||
}
|
||||
catch (const std::invalid_argument& ia) {
|
||||
std::cerr << __FUNCTION__ << "Invalid argument: " << ia.what() << '\n';
|
||||
}
|
||||
catch (const std::out_of_range& oor) {
|
||||
std::cerr << __FUNCTION__ << "Out of Range error: " << oor.what() << '\n';
|
||||
}
|
||||
catch (const std::logic_error & ler) {
|
||||
std::cerr << __FUNCTION__ << "Logical error: " << ler.what() << '\n';
|
||||
}
|
||||
catch (...) {
|
||||
std::cerr << __FUNCTION__ << "Unknown error" << '\n';
|
||||
}
|
||||
unsigned long long product_id = 0;
|
||||
DataTypeConverter::strToInt(mRequestData.get("product[id]", "0"), product_id);
|
||||
|
||||
std::string order_id = mRequestData.get("order_id", "");
|
||||
auto param_error_order_id = new ParamError("HandleElopageRequestTask", "order_id", order_id.data());
|
||||
|
||||
@ -380,58 +366,18 @@ int HandleElopageRequestTask::run()
|
||||
sendErrorsAsEmail();
|
||||
return -4;
|
||||
}
|
||||
|
||||
// write email verification code into db
|
||||
UniLib::controller::TaskPtr saveEmailVerificationCode(new model::table::ModelInsertTask(emailVerification->getModel(), true));
|
||||
saveEmailVerificationCode->scheduleTask(saveEmailVerificationCode);
|
||||
auto em = EmailManager::getInstance();
|
||||
if (emailVerification->getModel()->insertIntoDB(false)) {
|
||||
int noEMail = 0;
|
||||
|
||||
std::string noEmailString = mRequestData.get("noEmail", "0");
|
||||
try {
|
||||
noEMail = stoi(noEmailString);
|
||||
}
|
||||
catch (const std::invalid_argument& ia) {
|
||||
std::cerr << __FUNCTION__ << " Invalid argument: " << ia.what() << ", str: " << noEmailString << '\n';
|
||||
}
|
||||
catch (const std::out_of_range& oor) {
|
||||
std::cerr << __FUNCTION__ << " Out of Range error: " << oor.what() << '\n';
|
||||
}
|
||||
catch (const std::logic_error & ler) {
|
||||
std::cerr << __FUNCTION__ << " Logical error: " << ler.what() << '\n';
|
||||
}
|
||||
catch (...) {
|
||||
std::cerr << __FUNCTION__ << " Unknown error" << '\n';
|
||||
}
|
||||
DataTypeConverter::strToInt(mRequestData.get("noEmail", "0"), noEMail);
|
||||
|
||||
if (noEMail != 1) {
|
||||
|
||||
// send email to user
|
||||
/*auto message = new Poco::Net::MailMessage;
|
||||
|
||||
message->addRecipient(Poco::Net::MailRecipient(Poco::Net::MailRecipient::PRIMARY_RECIPIENT, mEmail));
|
||||
message->setSubject("Gradido: E-Mail Verification");
|
||||
std::stringstream ss;
|
||||
ss << "Hallo " << mFirstName << " " << mLastName << "," << std::endl << std::endl;
|
||||
ss << "Du oder jemand anderes hat sich soeben mit dieser E-Mail Adresse bei Gradido registriert. " << std::endl;
|
||||
ss << "Wenn du es warst, klicke bitte auf den Link: " << ServerConfig::g_serverPath << "/checkEmail/" << emailVerification->getModel()->getCode() << std::endl;
|
||||
//ss << "oder kopiere den Code: " << mEmailVerificationCode << " selbst dort hinein." << std::endl;
|
||||
ss << "oder kopiere den obigen Link in Dein Browserfenster." << std::endl;
|
||||
ss << std::endl;
|
||||
|
||||
ss << "Mit freundlichen " << u8"Grüßen" << std::endl;
|
||||
ss << "Dario, Gradido Server Admin" << std::endl;
|
||||
|
||||
message->addContent(new Poco::Net::StringPartSource(ss.str()));
|
||||
*/
|
||||
//UniLib::controller::TaskPtr sendEmail(new SendEmailTask(message, ServerConfig::g_CPUScheduler, 1));
|
||||
//Email(AutoPtr<controller::EmailVerificationCode> emailVerification, AutoPtr<controller::User> user, EmailType type);
|
||||
UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(emailVerification, newUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
//sendEmail->setParentTaskPtrInArray(prepareEmail, 0);
|
||||
sendEmail->setParentTaskPtrInArray(saveEmailVerificationCode, 0);
|
||||
sendEmail->scheduleTask(sendEmail);
|
||||
em->addEmail(new model::Email(emailVerification, newUser, model::EMAIL_USER_VERIFICATION_CODE));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if errors occured, send via email
|
||||
if (errorCount() > 1) {
|
||||
addError(param_error_order_id);
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
#include "../SingletonManager/SingletonTaskObserver.h"
|
||||
|
||||
#include "../tasks/PrepareEmailTask.h"
|
||||
#include "../tasks/SendEmailTask.h"
|
||||
#include "../tasks/SigningTransaction.h"
|
||||
#include "../tasks/AuthenticatedEncryptionCreateKeyTask.h"
|
||||
#include "../tasks/VerificationEmailResendTask.h"
|
||||
@ -348,12 +346,14 @@ bool Session::createUser(const std::string& first_name, const std::string& last_
|
||||
*/
|
||||
//UniLib::controller::TaskPtr sendEmail(new SendEmailTask(message, ServerConfig::g_CPUScheduler, 1));
|
||||
//Email(AutoPtr<controller::EmailVerificationCode> emailVerification, AutoPtr<controller::User> user, EmailType type);
|
||||
UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
auto em = EmailManager::getInstance();
|
||||
em->addEmail(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE));
|
||||
/*UniLib::controller::TaskPtr sendEmail(new SendEmailTask(new model::Email(mEmailVerificationCodeObject, mNewUser, model::EMAIL_USER_VERIFICATION_CODE), ServerConfig::g_CPUScheduler, 1));
|
||||
//sendEmail->setParentTaskPtrInArray(prepareEmail, 0);
|
||||
sendEmail->setParentTaskPtrInArray(writeEmailVerification, 0);
|
||||
sendEmail->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_EMAIL_VERIFICATION_SEND, this));
|
||||
sendEmail->scheduleTask(sendEmail);
|
||||
|
||||
*/
|
||||
// write user into db
|
||||
// generate and write email verification into db
|
||||
// send email
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
#include "PrepareEmailTask.h"
|
||||
#include "../lib/Profiler.h"
|
||||
#include "../ServerConfig.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
|
||||
#include "Poco/Net/SSLException.h"
|
||||
|
||||
PrepareEmailTask::PrepareEmailTask(UniLib::controller::CPUSheduler* cpuScheduler)
|
||||
: UniLib::controller::CPUTask(cpuScheduler), mMailClientSession(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PrepareEmailTask::~PrepareEmailTask()
|
||||
{
|
||||
if (mMailClientSession) {
|
||||
delete mMailClientSession;
|
||||
}
|
||||
}
|
||||
|
||||
int PrepareEmailTask::run()
|
||||
{
|
||||
if (ServerConfig::g_disableEmail) return 0;
|
||||
Profiler timeUsed;
|
||||
mMailClientSession = new Poco::Net::SecureSMTPClientSession(ServerConfig::g_EmailAccount.url, ServerConfig::g_EmailAccount.port);
|
||||
mMailClientSession->login();
|
||||
try {
|
||||
mMailClientSession->startTLS(ServerConfig::g_SSL_CLient_Context);
|
||||
mMailClientSession->login(Poco::Net::SMTPClientSession::AUTH_LOGIN, ServerConfig::g_EmailAccount.username, ServerConfig::g_EmailAccount.password);
|
||||
} catch(Poco::Net::SSLException& ex) {
|
||||
printf("[PrepareEmailTask] ssl certificate error: %s\nPlease make sure you have cacert.pem (CA/root certificates) next to binary from https://curl.haxx.se/docs/caextract.html\n", ex.displayText().data());
|
||||
return -1;
|
||||
}
|
||||
|
||||
//printf("[PrepareEmailTask] time: %s\n", timeUsed.string().data());
|
||||
/*
|
||||
session.login();
|
||||
session.startTLS(pContext);
|
||||
if (!username.empty())
|
||||
{
|
||||
session.login(SMTPClientSession::AUTH_LOGIN, username, password);
|
||||
}
|
||||
session.sendMessage(message);
|
||||
session.close();
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PrepareEmailTask::send(Poco::Net::MailMessage* message)
|
||||
{
|
||||
if (ServerConfig::g_disableEmail) return 0;
|
||||
|
||||
auto er = ErrorManager::getInstance();
|
||||
try {
|
||||
mMailClientSession->sendMessage(*message);
|
||||
mMailClientSession->close();
|
||||
}
|
||||
catch (Poco::Exception& exc) {
|
||||
er->addError(new ParamError("PrepareEmailTask::send", "error sending email", exc.displayText().data()));
|
||||
printf("[PrepareEmailTask::%s] error sending email: %s\n", __FUNCTION__, exc.displayText().data());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
#ifndef GRADIDO_LOGIN_SERVER_TASKS_PREPAIRE_EMAIL_TASK_INCLUDE
|
||||
#define GRADIDO_LOGIN_SERVER_TASKS_PREPAIRE_EMAIL_TASK_INCLUDE
|
||||
|
||||
#include "CPUTask.h"
|
||||
#include "Poco/Net/SecureSMTPClientSession.h"
|
||||
|
||||
|
||||
|
||||
class PrepareEmailTask : public UniLib::controller::CPUTask
|
||||
{
|
||||
public:
|
||||
PrepareEmailTask(UniLib::controller::CPUSheduler* cpuScheduler);
|
||||
virtual ~PrepareEmailTask();
|
||||
|
||||
virtual int run();
|
||||
int send(Poco::Net::MailMessage* message);
|
||||
virtual const char* getResourceType() const { return "PrepareEmailTask"; };
|
||||
protected:
|
||||
|
||||
private:
|
||||
Poco::Net::SecureSMTPClientSession* mMailClientSession;
|
||||
};
|
||||
|
||||
|
||||
#endif //GRADIDO_LOGIN_SERVER_TASKS_PREPAIRE_EMAIL_TASK_INCLUDE
|
||||
@ -1,64 +0,0 @@
|
||||
#include "SendEmailTask.h"
|
||||
#include "PrepareEmailTask.h"
|
||||
#include "../lib/Profiler.h"
|
||||
#include "../SingletonManager/ErrorManager.h"
|
||||
#include "../SingletonManager/EmailManager.h"
|
||||
#include "../ServerConfig.h"
|
||||
|
||||
#include "Poco/Net/MediaType.h"
|
||||
|
||||
SendEmailTask::SendEmailTask(Poco::Net::MailMessage* mailMessage, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount/* = 0*/)
|
||||
: UniLib::controller::CPUTask(cpuScheduler, additionalTaskDependenceCount+1), mMailMessage(mailMessage), mEmail(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SendEmailTask::SendEmailTask(model::Email*email, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount/* = 0*/)
|
||||
: UniLib::controller::CPUTask(cpuScheduler, additionalTaskDependenceCount), mMailMessage(nullptr), mEmail(email)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SendEmailTask::~SendEmailTask()
|
||||
{
|
||||
if (mMailMessage) {
|
||||
delete mMailMessage;
|
||||
mMailMessage = nullptr;
|
||||
}
|
||||
if (mEmail) {
|
||||
delete mEmail;
|
||||
mEmail = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int SendEmailTask::run()
|
||||
{
|
||||
if(ServerConfig::g_disableEmail) return 0;
|
||||
|
||||
Profiler timeUsed;
|
||||
auto er = ErrorManager::getInstance();
|
||||
auto parent = getParent(0);
|
||||
|
||||
if (mMailMessage) {
|
||||
|
||||
if (strcmp(parent->getResourceType(), "PrepareEmailTask") != 0) {
|
||||
er->addError(new Error("SendEmailTask", "first parent isn't PrepareEmailTask"));
|
||||
er->sendErrorsAsEmail();
|
||||
return -1;
|
||||
}
|
||||
PrepareEmailTask* prepare = (PrepareEmailTask*)&(*parent);
|
||||
mMailMessage->setSender(ServerConfig::g_EmailAccount.sender);
|
||||
|
||||
if (prepare->send(mMailMessage)) {
|
||||
er->sendErrorsAsEmail();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (mEmail) {
|
||||
auto em = EmailManager::getInstance();
|
||||
em->addEmail(mEmail);
|
||||
mEmail = nullptr;
|
||||
}
|
||||
//printf("[SendEmailTask] time: %s\n", timeUsed.string().data());
|
||||
return 0;
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
#ifndef GRADIDO_LOGIN_SERVER_TASKS_SEND_EMAIL_TASK_INCLUDE
|
||||
#define GRADIDO_LOGIN_SERVER_TASKS_SEND_EMAIL_TASK_INCLUDE
|
||||
|
||||
#include "CPUTask.h"
|
||||
#include "Poco/Net/MailMessage.h"
|
||||
|
||||
#include "../model/email/Email.h"
|
||||
|
||||
/*
|
||||
* @author: Dario Rekowski
|
||||
*
|
||||
* @date: 29.09.19
|
||||
* @desc: Task for send an email, the first parent dependence pointer must be a prepare email task
|
||||
*/
|
||||
|
||||
|
||||
class SendEmailTask : public UniLib::controller::CPUTask
|
||||
{
|
||||
public:
|
||||
|
||||
SendEmailTask(Poco::Net::MailMessage* mailMessage, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount = 0);
|
||||
SendEmailTask(model::Email* email, UniLib::controller::CPUSheduler* cpuScheduler, size_t additionalTaskDependenceCount = 0);
|
||||
virtual ~SendEmailTask();
|
||||
|
||||
virtual int run();
|
||||
|
||||
virtual const char* getResourceType() const { return "SendEmailTask"; };
|
||||
protected:
|
||||
|
||||
private:
|
||||
Poco::Net::MailMessage* mMailMessage;
|
||||
model::Email* mEmail;
|
||||
};
|
||||
|
||||
|
||||
#endif //GRADIDO_LOGIN_SERVER_TASKS_SEND_EMAIL_TASK_INCLUDE
|
||||
@ -1,29 +1,12 @@
|
||||
#########################################################################################################
|
||||
# Build skeema
|
||||
#########################################################################################################
|
||||
FROM golang:1.14.4 as skeema_build
|
||||
RUN go get -d -v github.com/skeema/skeema
|
||||
WORKDIR /go/src/github.com/skeema/skeema
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/skeema .
|
||||
|
||||
#########################################################################################################
|
||||
# mariadb server
|
||||
#########################################################################################################
|
||||
From mariadb/server:10.5 as mariadb_server
|
||||
|
||||
ENV DOCKER_WORKDIR="/docker-entrypoint-initdb.d"
|
||||
#ENV DOCKER_WORKDIR="/skeema"
|
||||
|
||||
# copy skeema
|
||||
#COPY --from=skeema_build /go/bin/skeema /usr/bin/
|
||||
|
||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
#COPY ./mariadb/.skeema .
|
||||
#COPY ./login_server/skeema/ .
|
||||
#COPY ./mariadb/.skeema.login ./gradido_login/.skeema
|
||||
#COPY ./community_server/skeema/ .
|
||||
#RUN for f in *.c; do cp -- "$f" "$OTHERDIR/old#$f"; done
|
||||
|
||||
# create databases
|
||||
COPY ./mariadb/setup_dbs.sql a_setup_dbs.sql
|
||||
@ -35,52 +18,3 @@ COPY ./community_server/skeema/ .
|
||||
RUN cd ./gradido_community/ && for f in *.sql; do cp -- "$f" "../d_$f"; sed -i '1i use gradido_community;' "../d_$f"; done
|
||||
RUN cd ./gradido_community/insert && for f in *.sql; do cp -- "$f" "../../e_$f"; sed -i '1i use gradido_community;' "../../e_$f"; done
|
||||
|
||||
RUN ls -ls
|
||||
|
||||
|
||||
#USER mysql
|
||||
#VOLUME /var/lib/mysql
|
||||
#RUN mysqld
|
||||
#RUN mysql -e 'CREATE DATABASE gradido_login_server;'
|
||||
#RUN mysql -e 'CREATE DATABASE gradido_community_server;'
|
||||
|
||||
|
||||
#RUN skeema push
|
||||
|
||||
#########################################################################################################
|
||||
# mariadb server selfmade
|
||||
#########################################################################################################
|
||||
From alpine:latest as mariadb_DIV
|
||||
|
||||
ENV DOCKER_WORKDIR="/skeema"
|
||||
|
||||
#VOLUME /var/lib/mysql
|
||||
|
||||
#RUN apt-get update \
|
||||
# && apt-get -y --no-install-recommends install mariadb-server mariadb-client \
|
||||
# && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
|
||||
RUN apk add mariadb mariadb-client
|
||||
|
||||
# copy skeema
|
||||
COPY --from=skeema_build /go/bin/skeema /usr/bin/
|
||||
|
||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
|
||||
COPY ./mariadb/setup_dbs.sh .
|
||||
COPY ./mariadb/.skeema .
|
||||
COPY ./login_server/skeema/ .
|
||||
COPY ./mariadb/.skeema.login ./gradido_login/.skeema
|
||||
COPY ./community_server/skeema/ .
|
||||
COPY ./mariadb/.skeema.community ./gradido_community/.skeema
|
||||
|
||||
USER mysql
|
||||
#VOLUME /var/lib/mysql
|
||||
#RUN mysqld
|
||||
#RUN chmod +x ./setup_dbs.sh
|
||||
#RUN mysql < setup_dbs.sql
|
||||
#RUN skeema push
|
||||
|
||||
#EXPOSE 3306
|
||||
|
||||
#CMD ["mysld"]
|
||||
5
skeema/.skeema
Normal file
5
skeema/.skeema
Normal file
@ -0,0 +1,5 @@
|
||||
[production]
|
||||
flavor=mariadb:10.5
|
||||
host=mariadb
|
||||
port=3306
|
||||
user=root
|
||||
28
skeema/Dockerfile
Normal file
28
skeema/Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
#########################################################################################################
|
||||
# Build skeema
|
||||
#########################################################################################################
|
||||
FROM golang:1.14.4 as skeema_build
|
||||
RUN go get -d -v github.com/skeema/skeema
|
||||
WORKDIR /go/src/github.com/skeema/skeema
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/skeema .
|
||||
|
||||
#########################################################################################################
|
||||
# Run skeema
|
||||
#########################################################################################################
|
||||
From alpine:latest as skeema_run
|
||||
|
||||
ENV DOCKER_WORKDIR="/skeema"
|
||||
|
||||
# copy skeema
|
||||
COPY --from=skeema_build /go/bin/skeema /usr/bin/
|
||||
|
||||
RUN mkdir -p ${DOCKER_WORKDIR}
|
||||
WORKDIR ${DOCKER_WORKDIR}
|
||||
|
||||
COPY ./skeema/.skeema .
|
||||
COPY ./login_server/skeema/ .
|
||||
COPY ./mariadb/.skeema.login ./gradido_login/.skeema
|
||||
COPY ./community_server/skeema/ .
|
||||
COPY ./mariadb/.skeema.community ./gradido_community/.skeema
|
||||
|
||||
CMD skeema push
|
||||
Loading…
x
Reference in New Issue
Block a user