leadguru-jobs 0.600.0__py3-none-any.whl → 0.602.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: leadguru_jobs
3
- Version: 0.600.0
3
+ Version: 0.602.0
4
4
  Summary: LGT jobs builds
5
5
  Author-email: developer@leadguru.co
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -12,7 +12,7 @@ lgt_jobs/assets/images/logo.png,sha256=nt377FGkBalBF9Z9TYQRv9loHolTXwU8_VRYvCXXz
12
12
  lgt_jobs/assets/images/mail.png,sha256=eORzQcAMkFr7DjgtABVhJ_zFuXgO7OXv78lLF4b39B0,7168
13
13
  lgt_jobs/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  lgt_jobs/jobs/analytics.py,sha256=IIsWt4A1qUw3w-S-8W16uKY1FRVWfXXA41_mu4uCNiM,979
15
- lgt_jobs/jobs/bot_stats_update.py,sha256=yDA6-FqSC5T2jTPaHImSjnuI6OD0pw-BF9VagsfmkXM,7806
15
+ lgt_jobs/jobs/bot_stats_update.py,sha256=KYO0QbtM6oHFNTtoVyCBHpbIF8Yr_YOvWUWn-UzYoLA,8115
16
16
  lgt_jobs/jobs/chat_history.py,sha256=KiwiPl8FuI7FphfZT5VgKSTiO_W9j7tNyiSbnSe5GAs,6106
17
17
  lgt_jobs/jobs/connect_sources.py,sha256=_eA86KnS3AC6YCI1xk7VCV7lFmPRxta-wUStfdmajQU,4790
18
18
  lgt_jobs/jobs/inbox_leads.py,sha256=OSX-FNx27gWEKNBBc-hyq2odCxXytz7WHtQJajtz274,5670
@@ -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=967-kqdr8pxaRtd2XA_l6egnVGS5uv_tXN-YuDO9u34,3058
23
+ lgt_jobs/jobs/update_slack_profile.py,sha256=kQkhdaki5JaLZC7-Eu69u6O26jqsa1AD5PYU64CX6NU,3151
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
@@ -48,7 +48,7 @@ lgt_jobs/lgt_data/mongo_repository.py,sha256=kLE906lfqhHF9gp1qvH_3XKCZGCZnxjLMrB
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.600.0.dist-info/METADATA,sha256=crJRF31_1xkPv2y14MmxG2GepAdiJ7bDKnvMEq6CZTs,1319
52
- leadguru_jobs-0.600.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
53
- leadguru_jobs-0.600.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
54
- leadguru_jobs-0.600.0.dist-info/RECORD,,
51
+ leadguru_jobs-0.602.0.dist-info/METADATA,sha256=C76FrFWdvswVhQbx_b_Z082Ba9yZSZ3ngPvvqAHeEgw,1319
52
+ leadguru_jobs-0.602.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
53
+ leadguru_jobs-0.602.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
54
+ leadguru_jobs-0.602.0.dist-info/RECORD,,
@@ -1,6 +1,7 @@
1
1
  import random
2
2
  import time
3
3
  from abc import ABC
4
+ from datetime import datetime, UTC, timedelta
4
5
  from typing import Optional
5
6
  from lgt_jobs.lgt_common.discord_client.discord_client import DiscordClient
6
7
  from lgt_jobs.lgt_common.helpers import get_formatted_bot_name
@@ -32,6 +33,15 @@ class BotStatsUpdateJob(BaseBackgroundJob, ABC):
32
33
  bots_rep = DedicatedBotRepository()
33
34
  users_rep = UserMongoRepository()
34
35
  bot = bots_rep.get_one(id=data.bot_id, include_deleted=True)
36
+
37
+ user = users_rep.get(bot.user_id)
38
+ if user.subscription_expired_at.replace(tzinfo=UTC) < (datetime.now(UTC) - timedelta(7)):
39
+ bot.deleted = True
40
+ for server in bot.servers:
41
+ server.deleted = True
42
+ bots_rep.add_or_update(bot)
43
+ return
44
+
35
45
  received_messages, filtered_messages = get_bots_aggregated_analytics(bot_ids=[str(bot.id)])
36
46
 
37
47
  if bot.source.source_type == SourceType.DISCORD:
@@ -48,7 +58,6 @@ class BotStatsUpdateJob(BaseBackgroundJob, ABC):
48
58
  return
49
59
 
50
60
  discord_servers = [Server.from_dic(server) for server in servers_response]
51
- user = users_rep.get(bot.user_id)
52
61
  discord_user: DiscordUser = user.get_discord_user(bot.user_name)
53
62
  available_channels_types = [0, 5]
54
63
  if discord_user:
@@ -30,6 +30,11 @@ class UpdateExternalUserProfileJob(BaseBackgroundJob, ABC):
30
30
 
31
31
  @staticmethod
32
32
  def __update_slack_profile(user: UserModel, slack: SlackClient):
33
+ slack.update_profile(user.slack_profile.to_dic())
34
+ if user.photo_url:
35
+ photo_url = SlackFilesClient().get_file_url(user.photo_url)
36
+ slack.update_profile_photo(photo_url)
37
+
33
38
  profile = slack.get_team_profile()
34
39
  title_section_id = None
35
40
  title_field_id = None
@@ -39,29 +44,25 @@ class UpdateExternalUserProfileJob(BaseBackgroundJob, ABC):
39
44
  title_section_id = field_data.get('section_id')
40
45
  title_field_id = field_data.get('id')
41
46
  break
42
- for section_data in profile.get('profile', {}).get('sections', []):
43
- if section_data.get('section_type') == 'additional_info':
44
- skype_section_id = section_data.get('id')
45
- break
47
+ if title_field_id and title_section_id:
48
+ for section_data in profile.get('profile', {}).get('sections', []):
49
+ if section_data.get('section_type') == 'additional_info':
50
+ skype_section_id = section_data.get('id')
51
+ break
46
52
 
47
- slack.update_profile(user.slack_profile.to_dic())
48
- auth = slack.test_auth().json()
49
- user_id = auth.get('user_id')
50
- title_element_id = title_field_id.replace(title_field_id[:2], 'Pe')
51
- response = slack.update_section(user_id, title_section_id, title_element_id, user.slack_profile.title)
52
- sections = response['result']['data']['setProfileSection']['profileSections']
53
- elements = []
54
- for section in sections:
55
- if section['type'] == 'ADDITIONAL_INFO':
56
- elements = section['profileElements']
57
- break
58
- skype_element_id = None
59
- for element in elements:
60
- if element['label'] == 'Skype':
61
- skype_element_id = element['elementId']
62
- break
63
- slack.update_section(user_id, skype_section_id, skype_element_id, user.slack_profile.skype)
64
- # try to update user photo
65
- if user.photo_url:
66
- photo_url = SlackFilesClient().get_file_url(user.photo_url)
67
- slack.update_profile_photo(photo_url)
53
+ auth = slack.test_auth().json()
54
+ user_id = auth.get('user_id')
55
+ 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, user.slack_profile.title)
57
+ sections = response['result']['data']['setProfileSection']['profileSections']
58
+ elements = []
59
+ for section in sections:
60
+ if section['type'] == 'ADDITIONAL_INFO':
61
+ elements = section['profileElements']
62
+ break
63
+ skype_element_id = None
64
+ for element in elements:
65
+ if element['label'] == 'Skype':
66
+ skype_element_id = element['elementId']
67
+ break
68
+ slack.update_section(user_id, skype_section_id, skype_element_id, user.slack_profile.skype)