leadguru-jobs 0.588.0__py3-none-any.whl → 0.590.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.588.0.dist-info → leadguru_jobs-0.590.0.dist-info}/METADATA +1 -1
- {leadguru_jobs-0.588.0.dist-info → leadguru_jobs-0.590.0.dist-info}/RECORD +9 -9
- lgt_jobs/jobs/chat_history.py +1 -2
- lgt_jobs/jobs/send_slack_message.py +1 -2
- lgt_jobs/lgt_common/slack_client/slack_client.py +6 -10
- lgt_jobs/lgt_common/slack_client/web_client.py +12 -11
- lgt_jobs/lgt_data/model.py +1 -0
- {leadguru_jobs-0.588.0.dist-info → leadguru_jobs-0.590.0.dist-info}/WHEEL +0 -0
- {leadguru_jobs-0.588.0.dist-info → leadguru_jobs-0.590.0.dist-info}/top_level.txt +0 -0
@@ -13,13 +13,13 @@ lgt_jobs/assets/images/mail.png,sha256=eORzQcAMkFr7DjgtABVhJ_zFuXgO7OXv78lLF4b39
|
|
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
15
|
lgt_jobs/jobs/bot_stats_update.py,sha256=yDA6-FqSC5T2jTPaHImSjnuI6OD0pw-BF9VagsfmkXM,7806
|
16
|
-
lgt_jobs/jobs/chat_history.py,sha256=
|
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
|
19
19
|
lgt_jobs/jobs/load_slack_people.py,sha256=az3Pl8_0nUXizShpCksH6XMHFALLkta4QpMr_MkM9Io,3199
|
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
|
-
lgt_jobs/jobs/send_slack_message.py,sha256=
|
22
|
+
lgt_jobs/jobs/send_slack_message.py,sha256=_fuzqgspl7KRO6h4IRJya6sMT5JTqq_czodKB87GYqM,2451
|
23
23
|
lgt_jobs/jobs/update_slack_profile.py,sha256=0fUHBd2gEBne52sTfxwji2Wu-oYDM5dLGsL-rHq5kwM,2765
|
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
|
@@ -36,19 +36,19 @@ lgt_jobs/lgt_common/pubsub/messages.py,sha256=rm7uKbxwDTWJqsVA8Kee-4YT58bThjCEV2
|
|
36
36
|
lgt_jobs/lgt_common/pubsub/pubsubfactory.py,sha256=rfUDooYuhBQ2pE9FdDxZOpXjbrvlpiiQLCGOtnTFbSg,2204
|
37
37
|
lgt_jobs/lgt_common/slack_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
38
|
lgt_jobs/lgt_common/slack_client/methods.py,sha256=ctKF_1UHEmSWaRsoGEgMZicVabV7eEufZ7pjxdMAx8g,1455
|
39
|
-
lgt_jobs/lgt_common/slack_client/slack_client.py,sha256=
|
40
|
-
lgt_jobs/lgt_common/slack_client/web_client.py,sha256=
|
39
|
+
lgt_jobs/lgt_common/slack_client/slack_client.py,sha256=XUwXQfjDC1etFjKlcmP2d5tUWbNzxjklBLHRobY3gsw,13820
|
40
|
+
lgt_jobs/lgt_common/slack_client/web_client.py,sha256=6ybC5v-oK-Kuat8qM2fskS6nCnA9cJ5U0yIKhp_Y4kM,4939
|
41
41
|
lgt_jobs/lgt_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
42
|
lgt_jobs/lgt_data/analytics.py,sha256=fiN88zcIxs_bRMmXL7ftp4FvBeJ5I7QBPE4tbwKJ39E,21689
|
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=I8_7GS1IXRML0SLT9e_PxY7To-4haVVg40YYdr_TGoM,28678
|
47
47
|
lgt_jobs/lgt_data/mongo_repository.py,sha256=kLE906lfqhHF9gp1qvH_3XKCZGCZnxjLMrBLWBy7doo,46099
|
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.590.0.dist-info/METADATA,sha256=XNIlY8XNPIlcXWBbqhIyMdX0pfPzxVO7F7XUTgKMRBE,1319
|
52
|
+
leadguru_jobs-0.590.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
53
|
+
leadguru_jobs-0.590.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
|
54
|
+
leadguru_jobs-0.590.0.dist-info/RECORD,,
|
lgt_jobs/jobs/chat_history.py
CHANGED
@@ -100,8 +100,7 @@ class LoadChatHistoryJob(BaseBackgroundJob, ABC):
|
|
100
100
|
if not messages:
|
101
101
|
return None
|
102
102
|
|
103
|
-
messages = [SlackMessageConvertService.from_slack_response(bot
|
104
|
-
bot.id, user.id) for m in messages]
|
103
|
+
messages = [SlackMessageConvertService.from_slack_response(bot, m, contact.sender_id) for m in messages]
|
105
104
|
new_messages = self._get_new_messages(contact, bot, messages)
|
106
105
|
chat_history = [message.to_dic() for message in new_messages]
|
107
106
|
self.chat_repo.upsert_messages(chat_history)
|
@@ -54,7 +54,6 @@ class SendSlackMessageJob(BaseBackgroundJob, ABC):
|
|
54
54
|
message = resp.get('message') if 'message' in resp \
|
55
55
|
else slack_client.conversation_replies(channel_id, resp['file_msg_ts'])['messages'][0]
|
56
56
|
|
57
|
-
message_model: ChatMessage = SlackMessageConvertService.from_slack_response(bot
|
58
|
-
data.sender_id, bot.id, user.id)
|
57
|
+
message_model: ChatMessage = SlackMessageConvertService.from_slack_response(bot, message, data.sender_id)
|
59
58
|
message_model.viewed = True
|
60
59
|
ChatRepository().upsert_messages([message_model.to_dic()])
|
@@ -179,12 +179,13 @@ class SlackClient:
|
|
179
179
|
url = f'{self.base_url}{SlackMethods.conversations_replies}?{self.__ts_payload(channel, id)}'
|
180
180
|
return requests.get(url=url, cookies=self.cookies).json()
|
181
181
|
|
182
|
-
def post_message(self, channel: str, text: str):
|
182
|
+
def post_message(self, channel: str, text: str, thread_ts: str = None):
|
183
183
|
import uuid
|
184
184
|
payload = {
|
185
185
|
'channel': channel,
|
186
186
|
'text': text,
|
187
|
-
'client_msg_id': str(uuid.uuid4())
|
187
|
+
'client_msg_id': str(uuid.uuid4()),
|
188
|
+
'thread_ts': thread_ts
|
188
189
|
}
|
189
190
|
url = f'{self.base_url}{SlackMethods.chat_post_message}'
|
190
191
|
return requests.post(url=url, cookies=self.cookies, headers=self.headers, data=payload).json()
|
@@ -201,17 +202,13 @@ class SlackClient:
|
|
201
202
|
payload = {'email': email}
|
202
203
|
headers = {'User-Agent': user_agent}
|
203
204
|
response = requests.post(f"{self.base_url}/{SlackMethods.check_email}", params=payload, headers=headers)
|
204
|
-
if response.status_code
|
205
|
-
return False
|
206
|
-
return response.json()['ok']
|
205
|
+
return response.json()['ok'] if response.status_code == 200 else False
|
207
206
|
|
208
207
|
def confirm_email(self, email: str, user_agent: str, locale: str = 'en-US') -> bool:
|
209
208
|
payload = {'email': email, 'locale': locale}
|
210
209
|
headers = {'User-Agent': user_agent}
|
211
210
|
response = requests.post(f"{self.base_url}/{SlackMethods.confirm_email}", params=payload, headers=headers)
|
212
|
-
if response.status_code
|
213
|
-
return False
|
214
|
-
return response.json()['ok']
|
211
|
+
return response.json()['ok'] if response.status_code == 200 else False
|
215
212
|
|
216
213
|
def confirm_code(self, email: str, code: str, user_agent: str) -> requests.Response:
|
217
214
|
payload = {'email': email, 'code': code}
|
@@ -249,8 +246,7 @@ class SlackClient:
|
|
249
246
|
|
250
247
|
def test_auth(self):
|
251
248
|
headers = {"Authorization": f"Bearer {self.token}"}
|
252
|
-
return requests.post(f"{self.base_url}/{SlackMethods.auth_test}", headers=headers,
|
253
|
-
cookies=self.cookies)
|
249
|
+
return requests.post(f"{self.base_url}/{SlackMethods.auth_test}", headers=headers, cookies=self.cookies)
|
254
250
|
|
255
251
|
def __user_info_payload(self, user):
|
256
252
|
payload = {
|
@@ -1,30 +1,31 @@
|
|
1
1
|
from google.cloud import storage
|
2
2
|
from datetime import datetime, timedelta
|
3
|
-
from lgt_jobs.lgt_data.model import ChatMessage, LeadGuruFile
|
3
|
+
from lgt_jobs.lgt_data.model import ChatMessage, LeadGuruFile, DedicatedBotModel
|
4
4
|
from lgt_jobs.lgt_common.slack_client.slack_client import SlackClient
|
5
5
|
from lgt_jobs.lgt_data.mongo_repository import to_object_id
|
6
6
|
|
7
7
|
|
8
8
|
class SlackMessageConvertService:
|
9
9
|
@staticmethod
|
10
|
-
def from_slack_response(
|
10
|
+
def from_slack_response(bot: DedicatedBotModel, message_data: dict, sender_id: str) -> ChatMessage:
|
11
11
|
result = ChatMessage()
|
12
12
|
result.sender_id = sender_id
|
13
|
-
result.bot_id =
|
14
|
-
result.text =
|
15
|
-
result.user =
|
16
|
-
result.id =
|
17
|
-
result.attachments =
|
13
|
+
result.bot_id = to_object_id(bot.id)
|
14
|
+
result.text = message_data.get('text', '')
|
15
|
+
result.user = message_data.get('user', '')
|
16
|
+
result.id = message_data.get('ts', '')
|
17
|
+
result.attachments = message_data.get('attachments', [])
|
18
18
|
result.files = []
|
19
|
-
result.user_id = to_object_id(user_id)
|
20
|
-
|
21
|
-
|
19
|
+
result.user_id = to_object_id(bot.user_id)
|
20
|
+
result.source_id = bot.source.source_id
|
21
|
+
if 'files' in message_data:
|
22
|
+
for file in message_data.get('files'):
|
22
23
|
if file.get('mode') != "tombstone" and file.get('url_private_download'):
|
23
24
|
leadguru_file = LeadGuruFile()
|
24
25
|
leadguru_file.id = file['id']
|
25
26
|
leadguru_file.content_type = file['mimetype']
|
26
27
|
leadguru_file.file_name = file['name']
|
27
|
-
leadguru_file.blob_path = f'slack_files/{
|
28
|
+
leadguru_file.blob_path = f'slack_files/{bot.user_name}/slack_files/{file["id"]}'
|
28
29
|
result.files.append(leadguru_file)
|
29
30
|
|
30
31
|
js_ticks = int(result.id.split('.')[0] + result.id.split('.')[1][3:])
|
lgt_jobs/lgt_data/model.py
CHANGED
File without changes
|
File without changes
|