leadguru-jobs 0.560.0__py3-none-any.whl → 0.562.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.560.0
3
+ Version: 0.562.0
4
4
  Summary: LGT jobs builds
5
5
  Author-email: developer@leadguru.co
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -14,7 +14,7 @@ lgt_jobs/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  lgt_jobs/jobs/analytics.py,sha256=IIsWt4A1qUw3w-S-8W16uKY1FRVWfXXA41_mu4uCNiM,979
15
15
  lgt_jobs/jobs/bot_stats_update.py,sha256=R6mf5FxhWbyx92AYXlj0FZVjz2Tgz86mBvLHrsQ9AFE,7502
16
16
  lgt_jobs/jobs/chat_history.py,sha256=tZ4XyOGdy1k6r4uotxSSKbXjTR_oRK6Ym0YthFYBtl8,6200
17
- lgt_jobs/jobs/connect_sources.py,sha256=CD15PKYrloepfr8fqUP0XkmvXb9VZDXfLNhYiiYeQ3U,3668
17
+ lgt_jobs/jobs/connect_sources.py,sha256=uVO_kH-Hxn7HkYUNGNcS7Mu3jB7KlB4pU5qcdtR2hrM,4260
18
18
  lgt_jobs/jobs/inbox_leads.py,sha256=EYxdQPseNBY5ON7BK3LpnXDCgQpzHTPLRJCZmZiAAHA,5582
19
19
  lgt_jobs/jobs/mass_message.py,sha256=1mFcBlL2MhzLbj5yrd_NyJc7TXDWCcROAzGDnr0miMU,2035
20
20
  lgt_jobs/jobs/send_code.py,sha256=dIlLPkG3GgGKIEqGiElyzrtdrnJNTL1Ak2V0xnE-WIQ,824
@@ -35,19 +35,19 @@ lgt_jobs/lgt_common/pubsub/messages.py,sha256=rm7uKbxwDTWJqsVA8Kee-4YT58bThjCEV2
35
35
  lgt_jobs/lgt_common/pubsub/pubsubfactory.py,sha256=rfUDooYuhBQ2pE9FdDxZOpXjbrvlpiiQLCGOtnTFbSg,2204
36
36
  lgt_jobs/lgt_common/slack_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  lgt_jobs/lgt_common/slack_client/methods.py,sha256=ctKF_1UHEmSWaRsoGEgMZicVabV7eEufZ7pjxdMAx8g,1455
38
- lgt_jobs/lgt_common/slack_client/slack_client.py,sha256=fxSTaU696yfe5tFWnuW6LuH4EUkgB2kdqDxQ96GYMJY,13799
38
+ lgt_jobs/lgt_common/slack_client/slack_client.py,sha256=icHapSOszFYnSofJ-eWl4lUWSOqng6S9XSRFfMx87Rg,13836
39
39
  lgt_jobs/lgt_common/slack_client/web_client.py,sha256=JrkEepL6EhEtX3Psv_sd25bcRB2P23LoGnFHcczQpnc,4778
40
40
  lgt_jobs/lgt_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  lgt_jobs/lgt_data/analytics.py,sha256=TFUffL8Dn-vIJ3ZaCVN-cj1Qnjb8F9GJyuk6Fo7mR1s,21645
42
42
  lgt_jobs/lgt_data/engine.py,sha256=Rsbz-CApAo_TVDssdjBkv8v_fVOZm_Uh1S6W4fnaEWo,7728
43
- lgt_jobs/lgt_data/enums.py,sha256=GZn6wm-kOd3veEOo1qlOR8QYje4vKaGV0na9jGt9388,2160
43
+ lgt_jobs/lgt_data/enums.py,sha256=jBH5WGBtDAvFrh4iiPIzlQ-XrImMpuwqstuasG55mJ0,2209
44
44
  lgt_jobs/lgt_data/helpers.py,sha256=NDa-V5EYaJfkGoWsmQSwSe6N_jxNxs8tHRQzW1iST6k,480
45
45
  lgt_jobs/lgt_data/model.py,sha256=BtVpJC_TRXUOklpzwRiDywyuKCCV2GGXtjsRYcPibDc,28454
46
46
  lgt_jobs/lgt_data/mongo_repository.py,sha256=wdhslZTfTU-3Ad4Gm8NVl9HZFM5aK_vgG47EqNQBARk,45179
47
47
  lgt_jobs/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  lgt_jobs/services/web_client.py,sha256=GLWsJkIC8rv6xLFaLwcMm4EwBlVDu0njORwkZqBJaE4,2086
49
49
  lgt_jobs/templates/new_message.html,sha256=BD_E90akmQ1Wf07wtZAjeK_7DUKRmja5HFHVo_AKI24,6994
50
- leadguru_jobs-0.560.0.dist-info/METADATA,sha256=XVDHeHX-orfiXiagPSBZcEy-RWZn4KWAvEBv2Bmvc7M,1319
51
- leadguru_jobs-0.560.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
52
- leadguru_jobs-0.560.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
53
- leadguru_jobs-0.560.0.dist-info/RECORD,,
50
+ leadguru_jobs-0.562.0.dist-info/METADATA,sha256=KoLJrkMpvPsywYTmEQy6vwxcHtLNXubHITY0VZbN4xY,1319
51
+ leadguru_jobs-0.562.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
52
+ leadguru_jobs-0.562.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
53
+ leadguru_jobs-0.562.0.dist-info/RECORD,,
@@ -28,55 +28,63 @@ class ConnectSourceJob(BaseBackgroundJob, ABC):
28
28
  action_user = users_repository.get_by_email(data.action_user_email)
29
29
  user = users_repository.get_by_email(data.user_email)
30
30
  if not action_user:
31
- log.info(f'Unable to find user with email: {data.action_user_email}')
31
+ log.info(f'[ConnectSourceJobData]: Unable to find user with email: {data.action_user_email}')
32
32
  return
33
33
 
34
34
  slack_user: SlackUser = action_user.get_slack_user(data.slack_email)
35
35
  if not slack_user:
36
- log.info(f"You have no credentials for {data.slack_email}. Try to login to Slack.")
36
+ log.info(f"[ConnectSourceJobData]: You have no credentials for {data.slack_email}. Try to login to Slack.")
37
+ slack_user.status = StatusConnection.COMPLETE
38
+ users_repository.set(action_user.id, slack_users=[user.to_dic() for user in action_user.slack_users])
39
+ return
37
40
  bots = []
38
41
  for ws in slack_user.workspaces:
39
- if ws.id in data.sources_ids:
40
- active_bot = bots_repository.get_one(user_id=action_user.id, active_server_id=ws.id)
41
- bot = bots_repository.get_one(user_id=action_user.id, server_id=ws.id, include_deleted=True,
42
- user_name=data.slack_email)
43
- if active_bot:
44
- continue
45
- if not bot:
46
- bot = DedicatedBotModel()
47
- bot.servers = [Server()]
42
+ try:
43
+ if ws.id in data.sources_ids:
44
+ active_bot = bots_repository.get_one(user_id=action_user.id, active_server_id=ws.id)
45
+ bot = bots_repository.get_one(user_id=action_user.id, server_id=ws.id, include_deleted=True,
46
+ user_name=data.slack_email)
47
+ if active_bot:
48
+ continue
49
+ if not bot:
50
+ bot = DedicatedBotModel()
51
+ bot.servers = [Server()]
48
52
 
49
- bot.user_name = slack_user.email
50
- bot.slack_url = ws.url
51
- bot.user_id = action_user.id
52
- bot.created_by = user.email
53
- bot.registration_link = ws.url
54
- bot.token = ws.token
55
- bot.cookies = slack_user.cookies
56
- bot.deleted = False
57
- bot.paused = False
58
- bot.invalid_creds = False
59
- bot.banned = False
60
- bot.two_factor_required = ws.two_factor_required
61
- source = Source()
53
+ bot.user_name = slack_user.email
54
+ bot.slack_url = ws.url
55
+ bot.user_id = action_user.id
56
+ bot.created_by = user.email
57
+ bot.registration_link = ws.url
58
+ bot.token = ws.token
59
+ bot.cookies = slack_user.cookies
60
+ bot.deleted = False
61
+ bot.paused = False
62
+ bot.invalid_creds = False
63
+ bot.banned = False
64
+ bot.two_factor_required = ws.two_factor_required
65
+ source = Source()
62
66
 
63
- for server in bot.servers:
64
- server.id = ws.id
65
- server.name = ws.domain
66
- server.deleted = False
67
- server.active = True
68
- server.icon = ws.icon
67
+ for server in bot.servers:
68
+ server.id = ws.id
69
+ server.name = ws.domain
70
+ server.deleted = False
71
+ server.active = True
72
+ server.icon = ws.icon
69
73
 
70
- source.source_id = ws.id
71
- source.source_name = ws.domain
72
- bot.type = source.source_type = SourceType.SLACK
73
- bot.icon = ws.icon
74
- bot.source = source
75
- bots_repository.add_or_update(bot)
76
- UserTrackAction.track(action_user.id, UserAction.START_SOURCE, ws.id)
77
- bot = bots_repository.get_one(user_id=action_user.id, server_id=ws.id, user_name=slack_user.email)
78
- bots.append(bot)
79
- BackgroundJobRunner.submit(BotStatsUpdateJob, BotStatsUpdateJobData(bot_id=str(bot.id)))
74
+ source.source_id = ws.id
75
+ source.source_name = ws.domain
76
+ bot.type = source.source_type = SourceType.SLACK
77
+ bot.icon = ws.icon
78
+ bot.source = source
79
+ bots_repository.add_or_update(bot)
80
+ UserTrackAction.track(action_user.id, UserAction.START_SOURCE, ws.id)
81
+ bot = bots_repository.get_one(user_id=action_user.id, server_id=ws.id, user_name=slack_user.email)
82
+ bots.append(bot)
83
+ BackgroundJobRunner.submit(BotStatsUpdateJob, BotStatsUpdateJobData(bot_id=str(bot.id)))
84
+ except Exception:
85
+ import traceback
86
+ log.exception(f"[ConnectSourceJobData]: Error to connect {ws.id}")
87
+ traceback.print_exc()
80
88
  slack_user.status = StatusConnection.COMPLETE
81
89
  users_repository.set(action_user.id, slack_users=[user.to_dic() for user in action_user.slack_users])
82
90
  return bots
@@ -54,13 +54,14 @@ class SlackClient:
54
54
 
55
55
  def users_list(self, cursor=None, limit: int = 1000):
56
56
  url = f'{self.base_url}{SlackMethods.users_list}'
57
+ payload = {}
57
58
  if cursor:
58
- url += f'&cursor={cursor}'
59
+ payload['cursor'] = cursor
59
60
 
60
61
  if limit:
61
- url += f'&limit={limit}'
62
+ payload['limit'] = limit
62
63
 
63
- return requests.get(url=url, cookies=self.cookies, headers=self.headers).json()
64
+ return requests.get(url=url, cookies=self.cookies, headers=self.headers, params=payload).json()
64
65
 
65
66
  def upload_file(self, file, file_name):
66
67
  payload = {"content": file, "filename": file_name}
@@ -43,6 +43,7 @@ class UserAction(str, Enum):
43
43
 
44
44
 
45
45
  class StatusConnection(str, Enum):
46
+ SOURCES_IN_PROGRESS = 'Sources in progress',
46
47
  IN_PROGRESS = 'In progress',
47
48
  COMPLETE = 'Complete',
48
49
  FAILED = 'Failed'