fix: exclude admin/system users from all third-party API tasks
Catalog, VK catalog, and VK sync tasks were querying all connections regardless of user role. Admin and system accounts with stored tokens were generating unnecessary Evotor and VK API calls. Now all three tasks join to the users table and filter role = 'user' only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ from web.models.connections import (
|
||||
SyncConfig, SyncFilter,
|
||||
VkCachedAlbum, VkConnection,
|
||||
)
|
||||
from web.models.user import User, UserRoleEnum
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -412,12 +413,14 @@ def mirror_to_vk(self) -> dict:
|
||||
try:
|
||||
vk_connections = (
|
||||
db.query(VkConnection)
|
||||
.join(User, User.id == VkConnection.user_id)
|
||||
.filter(
|
||||
VkConnection.user_id.isnot(None),
|
||||
VkConnection.access_token.isnot(None),
|
||||
VkConnection.access_token != "",
|
||||
VkConnection.vk_user_id.isnot(None),
|
||||
VkConnection.vk_user_id != "",
|
||||
User.role == UserRoleEnum.user,
|
||||
)
|
||||
.all()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user