ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: синхронизация профиля Tasker

This commit is contained in:
DCCONSTRUCTIONS
2026-05-12 17:57:57 +03:00
parent 480f85cce8
commit 1f7ecc39a0
4 changed files with 159 additions and 3 deletions
@@ -52,9 +52,12 @@ from plane.utils.host import base_host
from plane.bgtasks.user_email_update_task import send_email_update_magic_code, send_email_update_confirmation
from plane.authentication.rate_limit import EmailVerificationThrottle
from plane.license.utils.instance_value import get_configuration_value
from plane.app.realtime.nodedc_events import publish_nodedc_user_profile_event_on_commit
from plane.authentication.nodedc_profile_sync import push_nodedc_user_profile_update_on_commit
logger = logging.getLogger("plane")
NODEDC_PROFILE_SYNC_FIELDS = ("display_name", "first_name", "last_name", "avatar")
class UserEndpoint(BaseViewSet):
@@ -91,7 +94,21 @@ class UserEndpoint(BaseViewSet):
return Response({"is_instance_admin": is_admin}, status=status.HTTP_200_OK)
def partial_update(self, request, *args, **kwargs):
return super().partial_update(request, *args, **kwargs)
user = self.get_object()
previous_profile = {field: getattr(user, field, None) for field in NODEDC_PROFILE_SYNC_FIELDS}
response = super().partial_update(request, *args, **kwargs)
if response.status_code < 400:
user.refresh_from_db()
changed_fields = [
field for field in NODEDC_PROFILE_SYNC_FIELDS if previous_profile.get(field) != getattr(user, field, None)
]
if changed_fields:
publish_nodedc_user_profile_event_on_commit(user, changed_fields=changed_fields)
push_nodedc_user_profile_update_on_commit(user, changed_fields=changed_fields)
return response
def _validate_new_email(self, user, new_email):
"""