diff --git a/Changelog b/Changelog
index 69c44d2be..789b5762c 100755
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
2018-06-04 DariusIII
+ * Chg: Add dynamic api throthling
* Fix: Fix headers that are being sent with getNzb function
* Fix: Make queries properly formatted for API V2
* Chg: Remove references to extended info in API V2, API always sends extended information
diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php
index 9fb3fcc70..e0d4bcb8a 100644
--- a/app/Http/Controllers/Admin/UserController.php
+++ b/app/Http/Controllers/Admin/UserController.php
@@ -92,6 +92,7 @@ class UserController extends BasePageController
'password' => '',
'role' => User::ROLE_USER,
'notes' => '',
+ 'rate_limit' => 60,
];
$title = 'View User';
diff --git a/app/Models/User.php b/app/Models/User.php
index 2a0f3f43a..ad08720d0 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -332,6 +332,8 @@ class User extends Authenticatable
$userName = trim($userName);
$email = trim($email);
+ $rateLimit = UserRole::query()->where('id', $role)->value('rate_limit');
+
if (! self::isValidUsername($userName)) {
return self::ERR_SIGNUP_BADUNAME;
}
@@ -380,6 +382,7 @@ class User extends Authenticatable
'nzbvortex_api_key' => $nzbvortexApiKey,
'cp_url' => $cp_url,
'cp_api' => $cp_api,
+ 'rate_limit' => $rateLimit,
];
self::query()->where('id', $id)->update($sql);
@@ -888,6 +891,8 @@ class User extends Authenticatable
return false;
}
+ $rateLimit = UserRole::query()->where('id', $role)->value('rate_limit');
+
if (\defined('NN_INSTALLER')) {
$storeips = '';
} else {
@@ -906,6 +911,7 @@ class User extends Authenticatable
'invitedby' => (int) $invitedBy === 0 ? 'NULL' : $invitedBy,
'userseed' => md5(Utility::generateUuid()),
'notes' => $notes,
+ 'rate_limit' => $rateLimit,
]
)->id;
}
diff --git a/app/Models/UserRole.php b/app/Models/UserRole.php
index 79f4bab5c..d8fcfbb08 100644
--- a/app/Models/UserRole.php
+++ b/app/Models/UserRole.php
@@ -104,6 +104,7 @@ class UserRole extends Model
'hideads' => $request['hideads'],
'donation' => $request['donation'],
'addyears' => $request['addyears'],
+ 'rate_limit' => $request['rate_limit'],
]
);
}
@@ -126,6 +127,7 @@ class UserRole extends Model
'hideads' => $request['hideads'],
'donation' => $request['donation'],
'addyears' => $request['addyears'],
+ 'rate_limit' => $request['rate_limit'],
]
);
}
diff --git a/build/nntmux.xml b/build/nntmux.xml
index 69a42ebed..2dd465311 100755
--- a/build/nntmux.xml
+++ b/build/nntmux.xml
@@ -16,8 +16,8 @@