leadguru-jobs 0.608.0__py3-none-any.whl → 0.610.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.608.0
3
+ Version: 0.610.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=KYO0QbtM6oHFNTtoVyCBHpbIF8Yr_YOvWUWn-UzYoLA,8115
15
+ lgt_jobs/jobs/bot_stats_update.py,sha256=JRPPyqFvGHWuH_NQJNzIDy3DC0Joz14goNExqp-YUrw,8683
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
@@ -22,9 +22,9 @@ lgt_jobs/jobs/send_code.py,sha256=dIlLPkG3GgGKIEqGiElyzrtdrnJNTL1Ak2V0xnE-WIQ,82
22
22
  lgt_jobs/jobs/send_slack_message.py,sha256=_fuzqgspl7KRO6h4IRJya6sMT5JTqq_czodKB87GYqM,2451
23
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
- lgt_jobs/jobs/workspace_connect.py,sha256=LSZkkuPuHTqxvaTgqz_Y_kGIkF3Mmn_xwKf2h0uDWVg,7115
25
+ lgt_jobs/jobs/workspace_connect.py,sha256=y48LGLtH7KxB-XAja9JOW4VFq4rzJh8cSf6heNBLSx0,7067
26
26
  lgt_jobs/lgt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- lgt_jobs/lgt_common/helpers.py,sha256=tJNrKJYPa_MBmfRVrpHryoOWe4gnv7xOlmHuTh-bMBw,428
27
+ lgt_jobs/lgt_common/helpers.py,sha256=3T47_Abw7datSIxVqIHTCB-sh-rnahWrmrFG8sSY9ZE,178
28
28
  lgt_jobs/lgt_common/lgt_logging.py,sha256=Zxr2sPpY-qU_YbL_47OM6dE_JA1ejG_Vr1PNnjF_jwo,576
29
29
  lgt_jobs/lgt_common/discord_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  lgt_jobs/lgt_common/discord_client/discord_client.py,sha256=IA5JgoZq-oowkEGLRReZbW4Wa7cTtdSTPfGKF6ymNm8,4067
@@ -44,11 +44,11 @@ lgt_jobs/lgt_data/engine.py,sha256=Rsbz-CApAo_TVDssdjBkv8v_fVOZm_Uh1S6W4fnaEWo,7
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
46
  lgt_jobs/lgt_data/model.py,sha256=7a10N7WAqX2ZdstHTQrvp87rtYB9UPhWLidOYQJnKXM,29040
47
- lgt_jobs/lgt_data/mongo_repository.py,sha256=i45iPEUA9ggS5hALXtRlCIywC-bW6TO7G-Ud0fM_G3o,46228
47
+ lgt_jobs/lgt_data/mongo_repository.py,sha256=m1UHtBwiZ8JGIMZ6ud2PZadm8sgq4InG0glR7-sBLwE,46849
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.608.0.dist-info/METADATA,sha256=t44AqrsdQH9j8Sxtci8GI2rK1x6BQsoYsD5tHZFj-3g,1319
52
- leadguru_jobs-0.608.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
53
- leadguru_jobs-0.608.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
54
- leadguru_jobs-0.608.0.dist-info/RECORD,,
51
+ leadguru_jobs-0.610.0.dist-info/METADATA,sha256=DReiHwWbCG8Q0dsTyv_hU-LsnNjkvjmws7MRwHiIcRQ,1319
52
+ leadguru_jobs-0.610.0.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
53
+ leadguru_jobs-0.610.0.dist-info/top_level.txt,sha256=rIuw1DqwbnZyeoarBSC-bYeGOhv9mZBs7_afl9q4_JI,9
54
+ leadguru_jobs-0.610.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.2.0)
2
+ Generator: setuptools (70.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -4,11 +4,11 @@ from abc import ABC
4
4
  from datetime import datetime, UTC, timedelta
5
5
  from typing import Optional
6
6
  from lgt_jobs.lgt_common.discord_client.discord_client import DiscordClient
7
- from lgt_jobs.lgt_common.helpers import get_formatted_bot_name
8
7
  from lgt_jobs.lgt_common.slack_client.web_client import SlackWebClient
9
8
  from lgt_jobs.lgt_data.enums import SourceType
10
9
  from lgt_jobs.lgt_data.model import DedicatedBotModel, Server, Channel, DiscordUser
11
- from lgt_jobs.lgt_data.mongo_repository import DedicatedBotRepository, UserMongoRepository
10
+ from lgt_jobs.lgt_data.mongo_repository import (DedicatedBotRepository, UserMongoRepository, SlackContactUserRepository,
11
+ LeadMongoRepository, UserLeadMongoRepository)
12
12
  from pydantic import BaseModel
13
13
  from lgt_jobs.lgt_data.analytics import get_bots_aggregated_analytics
14
14
  import logging as log
@@ -113,12 +113,19 @@ class BotStatsUpdateJob(BaseBackgroundJob, ABC):
113
113
  log.warning(f"[BotStatsUpdateJob]: Error to get team info of {data.bot_id}. {test_auth_response.content}")
114
114
 
115
115
  if team_info.get('ok'):
116
- bot_name = get_formatted_bot_name(team_info['team']['domain'])
117
- if bot.servers:
118
- bot.servers[0].name = bot_name
119
- bot.source.source_name = bot_name
120
- bot.slack_url = bot.registration_link = team_info['team']['url']
121
- bots_rep.add_or_update(bot)
116
+ bot_name = team_info['team']['domain']
117
+ if bot.source.source_name != bot_name:
118
+ log.info(f"[BotStatsUpdateJob]: Updated source {bot.source.source_id}. "
119
+ f"Was {bot.source.source_name}, now {bot_name}")
120
+ if bot.servers:
121
+ bot.servers[0].name = bot_name
122
+ bot.source.source_name = bot_name
123
+ bot.slack_url = bot.registration_link = team_info['team']['url']
124
+ bots_rep.add_or_update(bot)
125
+ SlackContactUserRepository().update_source(bot.source.source_id, bot.source.__dict__)
126
+ UserLeadMongoRepository().update_source(bot.source.source_id, bot.source.__dict__)
127
+ LeadMongoRepository().update_source(bot.source.source_id, bot.source.__dict__)
128
+
122
129
  try:
123
130
  channels_response = client.channels_list()
124
131
  except:
@@ -1,7 +1,7 @@
1
1
  from abc import ABC
2
2
  from typing import Dict
3
3
  import requests
4
- from lgt_jobs.lgt_common.helpers import update_credentials, get_formatted_bot_name
4
+ from lgt_jobs.lgt_common.helpers import update_credentials
5
5
  from lgt_jobs.lgt_common.slack_client.web_client import SlackWebClient
6
6
  from lgt_jobs.lgt_data.enums import StatusConnection, SourceType
7
7
  from lgt_jobs.lgt_data.model import UserWorkspace, SlackUser, DedicatedBotModel
@@ -94,7 +94,7 @@ class ConnectSlackAccountJob(BaseBackgroundJob, ABC):
94
94
  token = sliced_content[:end_token_index]
95
95
  workspace.magic_login_url = login_url
96
96
  workspace.token = token
97
- workspace.domain = get_formatted_bot_name(workspace.domain)
97
+ workspace.domain = workspace.domain
98
98
 
99
99
  slack_user.cookies = session.cookies.get_dict()
100
100
  slack_user.workspaces = user_workspaces
@@ -1,18 +1,5 @@
1
- import re
2
-
3
-
4
1
  def update_credentials(credentials, token, cookies):
5
2
  credentials.token = token
6
3
  credentials.cookies = cookies
7
4
  credentials.invalid_creds = False
8
5
  return credentials
9
-
10
-
11
- def get_formatted_bot_name(name):
12
- bot_name = name
13
- bot_name.replace(" ", "_") \
14
- .replace(".", "dot_") \
15
- .replace("#", "") \
16
- .replace("+", "_plus")
17
-
18
- return re.sub(r'[^A-Za-z0-9]', "", bot_name).lower()
@@ -170,6 +170,10 @@ class UserLeadMongoRepository(BaseMongoRepository):
170
170
  collection_name = 'user_leads'
171
171
  model = ExtendedUserLeadModel
172
172
 
173
+ def update_source(self, source_id: str, source_data: dict):
174
+ self.collection().update_many({'message.source.source_id': source_id},
175
+ {'$set': {'message.source': source_data}})
176
+
173
177
  def get_many(self, ids: list, user_id):
174
178
  docs = self.collection().find({"id": {'$in': ids}, 'user_id': to_object_id(user_id)})
175
179
  leads = [ExtendedUserLeadModel.from_dic(lead) for lead in docs]
@@ -461,6 +465,10 @@ class LeadMongoRepository(BaseMongoRepository):
461
465
  collection_name = 'general_leads'
462
466
  model = LeadModel
463
467
 
468
+ def update_source(self, source_id: str, source_data: dict):
469
+ self.collection().update_many({'message.source.source_id': source_id},
470
+ {'$set': {'message.source': source_data}})
471
+
464
472
  def delete(self, _id):
465
473
  res = self.collection().delete_one({'id': _id})
466
474
  return res
@@ -944,6 +952,9 @@ class SlackContactUserRepository(BaseMongoRepository):
944
952
  pipeline = {"sender_id": user_id}
945
953
  return SlackMemberInformation.from_dic(self.collection().find_one(pipeline))
946
954
 
955
+ def update_source(self, source_id: str, source_data: dict):
956
+ self.collection().update_many({'source.source_id': source_id}, {'$set': {'source': source_data}})
957
+
947
958
 
948
959
  class UserTemplatesRepository(BaseMongoRepository):
949
960
  collection_name = "user_templates"