Skip to content

Commit

Permalink
Small updates to Slack user syncing (linkedin#382)
Browse files Browse the repository at this point in the history
* Small updates to Slack user syncing

Makes some small changes to make Slack user syncing work:

* Don't try to decode() the phone number, it's already a str

* Skip users with `is_bot` set

* Check if `phone` is nonempty before trying to parse

* Fix formatting error
  • Loading branch information
flooey authored Oct 11, 2022
1 parent 57e2ce4 commit c6991e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/oncall/notifier/reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def reminder(config):
WHERE `e`.`id` IS NULL AND `user`.`active` = 1
'''

while(1):
while (1):
logger.info('Reminder polling loop started')
window_end = int(time.time())

Expand Down
6 changes: 3 additions & 3 deletions src/oncall/user_sync/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def normalize_phone_number(num):
return format_number(parse(num.decode('utf-8'), 'US'), PhoneNumberFormat.INTERNATIONAL)
return format_number(parse(num, 'US'), PhoneNumberFormat.INTERNATIONAL)


def fetch_oncall_usernames(connection):
Expand Down Expand Up @@ -68,7 +68,7 @@ def sync_action(slack_client):
slack_users = {}

for m in slack_members:
if m['name'] == 'slackbot' or m['deleted']:
if m['name'] == 'slackbot' or m['deleted'] or m['is_bot']:
continue
user_profile = m['profile']
slack_users[m['name']] = {
Expand All @@ -77,7 +77,7 @@ def sync_action(slack_client):
'photo_url': user_profile['image_512'],
'email': user_profile['email'],
}
if 'phone' in user_profile:
if 'phone' in user_profile and user_profile['phone']:
slack_users[m['name']]['phone'] = normalize_phone_number(user_profile['phone'])

connection = db.connect()
Expand Down

0 comments on commit c6991e2

Please sign in to comment.