Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/PolicyController.php
Show All 37 Lines | public function greylist() | ||||
'response' => 'DUNNO', | 'response' => 'DUNNO', | ||||
'prepend' => [$prependGreylist] | 'prepend' => [$prependGreylist] | ||||
]; | ]; | ||||
return response()->json($result, 200); | return response()->json($result, 200); | ||||
} | } | ||||
/* | /* | ||||
* Apply a sensible rate limitation to a request. | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function ratelimit() | |||||
{ | |||||
/* | |||||
$data = [ | |||||
'instance' => 'test.local.instance', | |||||
'protocol_state' => 'RCPT', | |||||
'sender' => 'sender@spf-pass.kolab.org', | |||||
'client_name' => 'mx.kolabnow.com', | |||||
'client_address' => '212.103.80.148', | |||||
'recipient' => $this->domainOwner->email | |||||
]; | |||||
$response = $this->post('/api/webhooks/spf', $data); | |||||
*/ | |||||
$data = \request()->input(); | |||||
// TODO: normalize sender address | |||||
$sender = strtolower($data['sender']); | |||||
$alias = \App\UserAlias::where('alias', $sender)->first(); | |||||
if (!$alias) { | |||||
$user = \App\User::where('email', $sender)->first(); | |||||
if (!$user) { | |||||
// what's the situation here? | |||||
} | |||||
} else { | |||||
$user = $alias->user; | |||||
} | |||||
// TODO time-limit | |||||
$userRates = \App\Policy\Ratelimit::where('user_id', $user->id); | |||||
// TODO message vs. recipient limit | |||||
if ($userRates->count() > 10) { | |||||
// TODO | |||||
} | |||||
// this is the wallet to which the account is billed | |||||
$wallet = $user->wallet; | |||||
// TODO: consider $wallet->payments; | |||||
$owner = $wallet->user; | |||||
// TODO time-limit | |||||
$ownerRates = \App\Policy\Ratelimit::where('owner_id', $owner->id); | |||||
// TODO message vs. recipient limit (w/ user counts) | |||||
if ($ownerRates->count() > 10) { | |||||
// TODO | |||||
} | |||||
} | |||||
/* | |||||
* Apply the sender policy framework to a request. | * Apply the sender policy framework to a request. | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function senderPolicyFramework() | public function senderPolicyFramework() | ||||
{ | { | ||||
$data = \request()->input(); | $data = \request()->input(); | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |