leadguru-jobs 0.606.0__py3-none-any.whl → 0.607.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {leadguru_jobs-0.606.0.dist-info → leadguru_jobs-0.607.0.dist-info}/METADATA +1 -1
- {leadguru_jobs-0.606.0.dist-info → leadguru_jobs-0.607.0.dist-info}/RECORD +6 -6
- {leadguru_jobs-0.606.0.dist-info → leadguru_jobs-0.607.0.dist-info}/WHEEL +1 -1
- lgt_jobs/jobs/update_slack_profile.py +17 -11
- lgt_jobs/lgt_data/model.py +16 -6
- {leadguru_jobs-0.606.0.dist-info → leadguru_jobs-0.607.0.dist-info}/top_level.txt +0 -0
@@ -20,7 +20,7 @@ lgt_jobs/jobs/load_slack_people.py,sha256=az3Pl8_0nUXizShpCksH6XMHFALLkta4QpMr_M
|
|
20
20
|
lgt_jobs/jobs/mass_message.py,sha256=1mFcBlL2MhzLbj5yrd_NyJc7TXDWCcROAzGDnr0miMU,2035
|
21
21
|
lgt_jobs/jobs/send_code.py,sha256=dIlLPkG3GgGKIEqGiElyzrtdrnJNTL1Ak2V0xnE-WIQ,824
|
22
22
|
lgt_jobs/jobs/send_slack_message.py,sha256=_fuzqgspl7KRO6h4IRJya6sMT5JTqq_czodKB87GYqM,2451
|
23
|
-
lgt_jobs/jobs/update_slack_profile.py,sha256=
|
23
|
+
lgt_jobs/jobs/update_slack_profile.py,sha256=_ed0OhrVc1U-nE6dLckdmTmzZaxlK-y7h4S7SIpfEiA,3582
|
24
24
|
lgt_jobs/jobs/user_balance_update.py,sha256=HxeEmDdloK9EcoEj1ybYTgxIkB0IQNLnss_kk3rLI1Q,2404
|
25
25
|
lgt_jobs/jobs/workspace_connect.py,sha256=LSZkkuPuHTqxvaTgqz_Y_kGIkF3Mmn_xwKf2h0uDWVg,7115
|
26
26
|
lgt_jobs/lgt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -43,12 +43,12 @@ lgt_jobs/lgt_data/analytics.py,sha256=fiN88zcIxs_bRMmXL7ftp4FvBeJ5I7QBPE4tbwKJ39
|
|
43
43
|
lgt_jobs/lgt_data/engine.py,sha256=Rsbz-CApAo_TVDssdjBkv8v_fVOZm_Uh1S6W4fnaEWo,7728
|
44
44
|
lgt_jobs/lgt_data/enums.py,sha256=jBH5WGBtDAvFrh4iiPIzlQ-XrImMpuwqstuasG55mJ0,2209
|
45
45
|
lgt_jobs/lgt_data/helpers.py,sha256=NDa-V5EYaJfkGoWsmQSwSe6N_jxNxs8tHRQzW1iST6k,480
|
46
|
-
lgt_jobs/lgt_data/model.py,sha256=
|
46
|
+
lgt_jobs/lgt_data/model.py,sha256=7a10N7WAqX2ZdstHTQrvp87rtYB9UPhWLidOYQJnKXM,29040
|
47
47
|
lgt_jobs/lgt_data/mongo_repository.py,sha256=i45iPEUA9ggS5hALXtRlCIywC-bW6TO7G-Ud0fM_G3o,46228
|
48
48
|
lgt_jobs/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
49
|
lgt_jobs/services/web_client.py,sha256=GLWsJkIC8rv6xLFaLwcMm4EwBlVDu0njORwkZqBJaE4,2086
|
50
50
|
lgt_jobs/templates/new_message.html,sha256=dZl8UmdAOOMq4nidvAgMFroSrTV7Pw0RWt2yLp_2idg,6989
|
51
|
-
leadguru_jobs-0.
|
52
|
-
leadguru_jobs-0.
|
53
|
-
leadguru_jobs-0.
|
54
|
-
leadguru_jobs-0.
|
51
|
+
leadguru_jobs-0.607.0.dist-info/METADATA,sha256=cjiTrNHjeUn7ZNLBss1Yc8j7yWTBHrSfgiiwsaryoak,1319
|
52
|
+
leadguru_jobs-0.607.0.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
53
|
+
leadguru_jobs-0.607.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
|
54
|
+
leadguru_jobs-0.607.0.dist-info/RECORD,,
|
@@ -2,7 +2,7 @@ from abc import ABC
|
|
2
2
|
from lgt_jobs.lgt_common.slack_client.slack_client import SlackClient
|
3
3
|
from lgt_jobs.lgt_common.slack_client.web_client import SlackFilesClient
|
4
4
|
from lgt_jobs.lgt_data.enums import SourceType
|
5
|
-
from lgt_jobs.lgt_data.model import
|
5
|
+
from lgt_jobs.lgt_data.model import Profile, SlackUser
|
6
6
|
from lgt_jobs.lgt_data.mongo_repository import UserMongoRepository, DedicatedBotRepository
|
7
7
|
from pydantic import BaseModel
|
8
8
|
from lgt_jobs.basejobs import BaseBackgroundJobData, BaseBackgroundJob
|
@@ -21,31 +21,37 @@ class UpdateExternalUserProfileJob(BaseBackgroundJob, ABC):
|
|
21
21
|
|
22
22
|
def exec(self, data: UpdateExternalUserProfileJobData):
|
23
23
|
user = UserMongoRepository().get(data.user_id)
|
24
|
+
main_profile = None
|
25
|
+
active_users = [slack_user for slack_user in user.slack_users if not slack_user.deleted]
|
26
|
+
if active_users and active_users[0].profile.main:
|
27
|
+
main_profile = active_users[0].profile
|
24
28
|
bots = DedicatedBotRepository().get_all(user_id=data.user_id, only_valid=True, include_deleted=False)
|
25
29
|
for bot in bots:
|
30
|
+
current_user: SlackUser = next(filter(lambda x: x.email == bot.user_name, user.slack_users), None)
|
31
|
+
profile = main_profile if main_profile else current_user.profile
|
26
32
|
if bot.source.source_type == SourceType.SLACK:
|
27
33
|
slack = SlackClient(bot.token, bot.cookies)
|
28
34
|
log.info(f'Updating profile in {bot.source.source_name}:{bot.source.source_id}')
|
29
|
-
UpdateExternalUserProfileJob.__update_slack_profile(
|
35
|
+
UpdateExternalUserProfileJob.__update_slack_profile(slack, profile)
|
30
36
|
|
31
37
|
@staticmethod
|
32
|
-
def __update_slack_profile(
|
33
|
-
slack.update_profile(
|
34
|
-
if
|
35
|
-
photo_url = SlackFilesClient().get_file_url(
|
38
|
+
def __update_slack_profile(slack: SlackClient, profile: Profile = None):
|
39
|
+
slack.update_profile(profile.to_dic())
|
40
|
+
if profile.photo_url:
|
41
|
+
photo_url = SlackFilesClient().get_file_url(profile.photo_url)
|
36
42
|
slack.update_profile_photo(photo_url)
|
37
43
|
|
38
|
-
|
44
|
+
team_profile = slack.get_team_profile()
|
39
45
|
title_section_id = None
|
40
46
|
title_field_id = None
|
41
47
|
skype_section_id = None
|
42
|
-
for field_data in
|
48
|
+
for field_data in team_profile.get('profile', {}).get('fields', []):
|
43
49
|
if field_data.get('field_name') == 'title':
|
44
50
|
title_section_id = field_data.get('section_id')
|
45
51
|
title_field_id = field_data.get('id')
|
46
52
|
break
|
47
53
|
if title_field_id and title_section_id:
|
48
|
-
for section_data in
|
54
|
+
for section_data in team_profile.get('profile', {}).get('sections', []):
|
49
55
|
if section_data.get('section_type') == 'additional_info':
|
50
56
|
skype_section_id = section_data.get('id')
|
51
57
|
break
|
@@ -53,7 +59,7 @@ class UpdateExternalUserProfileJob(BaseBackgroundJob, ABC):
|
|
53
59
|
auth = slack.test_auth().json()
|
54
60
|
user_id = auth.get('user_id')
|
55
61
|
title_element_id = title_field_id.replace(title_field_id[:2], 'Pe')
|
56
|
-
response = slack.update_section(user_id, title_section_id, title_element_id,
|
62
|
+
response = slack.update_section(user_id, title_section_id, title_element_id, profile.title)
|
57
63
|
sections = response['result']['data']['setProfileSection']['profileSections']
|
58
64
|
elements = []
|
59
65
|
for section in sections:
|
@@ -65,4 +71,4 @@ class UpdateExternalUserProfileJob(BaseBackgroundJob, ABC):
|
|
65
71
|
if element['label'] == 'Skype':
|
66
72
|
skype_element_id = element['elementId']
|
67
73
|
break
|
68
|
-
slack.update_section(user_id, skype_section_id, skype_element_id,
|
74
|
+
slack.update_section(user_id, skype_section_id, skype_element_id, profile.skype)
|
lgt_jobs/lgt_data/model.py
CHANGED
@@ -272,8 +272,6 @@ class UserModel(BaseModel):
|
|
272
272
|
self.company_description: str = ''
|
273
273
|
self.position: str = ''
|
274
274
|
self.new_message_notified_at: Optional[datetime] = None
|
275
|
-
self.photo_url: str = ''
|
276
|
-
self.slack_profile = SlackProfile()
|
277
275
|
self.leads_limit: Optional[int] = None
|
278
276
|
self.leads_proceeded: Optional[int] = None
|
279
277
|
self.leads_filtered: Optional[int] = None
|
@@ -307,7 +305,7 @@ class UserModel(BaseModel):
|
|
307
305
|
if '_id' in dic:
|
308
306
|
setattr(model, 'id', dic['_id'])
|
309
307
|
|
310
|
-
model.slack_profile =
|
308
|
+
model.slack_profile = Profile.from_dic(dic.get('slack_profile'))
|
311
309
|
model.slack_users = [SlackUser.from_dic(user) for user in dic.get('slack_users', [])]
|
312
310
|
model.discord_users = [DiscordUser.from_dic(user) for user in dic.get('discord_users', [])]
|
313
311
|
return model
|
@@ -346,13 +344,17 @@ class DiscordUser(DictionaryModel):
|
|
346
344
|
self.status = None
|
347
345
|
self.workspaces: List[UserWorkspace] = []
|
348
346
|
self.deleted = False
|
347
|
+
self.profile: Profile | None = None
|
349
348
|
|
350
349
|
def to_dic(self):
|
351
350
|
result = copy.deepcopy(self.__dict__)
|
352
351
|
|
353
|
-
if result.get('workspaces'
|
352
|
+
if result.get('workspaces'):
|
354
353
|
result['workspaces'] = [ws.__dict__ for ws in result.get('workspaces')]
|
355
354
|
|
355
|
+
if result.get('profile'):
|
356
|
+
result['profile'] = result.get('profile').__dict__
|
357
|
+
|
356
358
|
return result
|
357
359
|
|
358
360
|
@classmethod
|
@@ -365,6 +367,7 @@ class DiscordUser(DictionaryModel):
|
|
365
367
|
setattr(model, k, v)
|
366
368
|
|
367
369
|
model.workspaces = [UserWorkspace.from_dic(ws) for ws in dic.get('workspaces', [])]
|
370
|
+
model.profile = Profile.from_dic(dic.get('profile'))
|
368
371
|
return model
|
369
372
|
|
370
373
|
|
@@ -378,6 +381,7 @@ class SlackUser:
|
|
378
381
|
self.status = None
|
379
382
|
self.workspaces: List[UserWorkspace] = []
|
380
383
|
self.deleted = False
|
384
|
+
self.profile: Profile | None = None
|
381
385
|
|
382
386
|
def to_dic(self):
|
383
387
|
result = copy.deepcopy(self.__dict__)
|
@@ -385,6 +389,9 @@ class SlackUser:
|
|
385
389
|
if result.get('workspaces', None):
|
386
390
|
result['workspaces'] = [ws.__dict__ for ws in result.get('workspaces')]
|
387
391
|
|
392
|
+
if result.get('profile'):
|
393
|
+
result['profile'] = result.get('profile').__dict__
|
394
|
+
|
388
395
|
return result
|
389
396
|
|
390
397
|
@classmethod
|
@@ -397,6 +404,7 @@ class SlackUser:
|
|
397
404
|
setattr(model, k, v)
|
398
405
|
|
399
406
|
model.workspaces = [UserWorkspace.from_dic(ws) for ws in dic.get('workspaces', [])]
|
407
|
+
model.profile = Profile.from_dic(dic.get('profile'))
|
400
408
|
return model
|
401
409
|
|
402
410
|
|
@@ -730,7 +738,7 @@ class BoardedStatus:
|
|
730
738
|
return model
|
731
739
|
|
732
740
|
|
733
|
-
class
|
741
|
+
class Profile:
|
734
742
|
pass
|
735
743
|
|
736
744
|
def __init__(self):
|
@@ -740,6 +748,8 @@ class SlackProfile:
|
|
740
748
|
self.display_name = ''
|
741
749
|
self.real_name = ''
|
742
750
|
self.email = ''
|
751
|
+
self.photo_url = ''
|
752
|
+
self.main = False
|
743
753
|
|
744
754
|
def to_dic(self):
|
745
755
|
return copy.deepcopy(self.__dict__)
|
@@ -754,7 +764,7 @@ class SlackProfile:
|
|
754
764
|
return model
|
755
765
|
|
756
766
|
|
757
|
-
class SlackMemberInformation(BaseModel,
|
767
|
+
class SlackMemberInformation(BaseModel, Profile):
|
758
768
|
workspace: str
|
759
769
|
sender_id: str
|
760
770
|
images: dict
|
File without changes
|