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.
- {leadguru_jobs-0.560.0.dist-info → leadguru_jobs-0.562.0.dist-info}/METADATA +1 -1
- {leadguru_jobs-0.560.0.dist-info → leadguru_jobs-0.562.0.dist-info}/RECORD +7 -7
- lgt_jobs/jobs/connect_sources.py +48 -40
- lgt_jobs/lgt_common/slack_client/slack_client.py +4 -3
- lgt_jobs/lgt_data/enums.py +1 -0
- {leadguru_jobs-0.560.0.dist-info → leadguru_jobs-0.562.0.dist-info}/WHEEL +0 -0
- {leadguru_jobs-0.560.0.dist-info → leadguru_jobs-0.562.0.dist-info}/top_level.txt +0 -0
@@ -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=
|
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=
|
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=
|
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.
|
51
|
-
leadguru_jobs-0.
|
52
|
-
leadguru_jobs-0.
|
53
|
-
leadguru_jobs-0.
|
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,,
|
lgt_jobs/jobs/connect_sources.py
CHANGED
@@ -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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
59
|
+
payload['cursor'] = cursor
|
59
60
|
|
60
61
|
if limit:
|
61
|
-
|
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}
|
lgt_jobs/lgt_data/enums.py
CHANGED
File without changes
|
File without changes
|