You've already forked oncall
mirror of
https://github.com/linkedin/oncall.git
synced 2025-11-28 23:20:23 +02:00
Small updates to Slack user syncing (#382)
* 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
This commit is contained in:
@@ -13,7 +13,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def normalize_phone_number(num):
|
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):
|
def fetch_oncall_usernames(connection):
|
||||||
@@ -68,7 +68,7 @@ def sync_action(slack_client):
|
|||||||
slack_users = {}
|
slack_users = {}
|
||||||
|
|
||||||
for m in slack_members:
|
for m in slack_members:
|
||||||
if m['name'] == 'slackbot' or m['deleted']:
|
if m['name'] == 'slackbot' or m['deleted'] or m['is_bot']:
|
||||||
continue
|
continue
|
||||||
user_profile = m['profile']
|
user_profile = m['profile']
|
||||||
slack_users[m['name']] = {
|
slack_users[m['name']] = {
|
||||||
@@ -77,7 +77,7 @@ def sync_action(slack_client):
|
|||||||
'photo_url': user_profile['image_512'],
|
'photo_url': user_profile['image_512'],
|
||||||
'email': user_profile['email'],
|
'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'])
|
slack_users[m['name']]['phone'] = normalize_phone_number(user_profile['phone'])
|
||||||
|
|
||||||
connection = db.connect()
|
connection = db.connect()
|
||||||
|
|||||||
Reference in New Issue
Block a user