@@ -1459,22 +1459,19 @@ def notify_user(self, changes):
1459
1459
return
1460
1460
1461
1461
# find out who changed the file(s), get the name if its only a single user
1462
-
1463
- user_name = None
1464
-
1465
- if all (getattr (x , "sharing_info" , None ) for x in changes .entries ):
1466
- # all files are in shared folder, see if the user IDs are the same
1467
- dbid0 = changes .entries [0 ].sharing_info .modified_by
1468
- if all (x .sharing_info .modified_by == dbid0 for x in changes .entries ):
1462
+ try :
1463
+ dbid_list = [md .sharing_info .modified_by for md in changes .entries ]
1464
+ if all (dbid == dbid_list [0 ] for dbid in dbid_list ):
1469
1465
# all files have been modified by the same user
1470
- if dbid0 == CONF .get ("account" , "account_id" ):
1466
+ if dbid_list [ 0 ] == CONF .get ("account" , "account_id" ):
1471
1467
user_name = "You"
1472
1468
else :
1473
- account_info = self .client .get_account_info (dbid0 )
1469
+ account_info = self .client .get_account_info (dbid_list [ 0 ] )
1474
1470
user_name = account_info .name .display_name
1475
- elif not any (getattr (x , "sharing_info" , None ) for x in changes .entries ):
1476
- # all files were changed by current user
1477
- user_name = "You"
1471
+ else :
1472
+ user_name = None
1473
+ except AttributeError :
1474
+ user_name = None
1478
1475
1479
1476
# notify user
1480
1477
if n_changed == 1 :
@@ -1484,25 +1481,25 @@ def notify_user(self, changes):
1484
1481
1485
1482
if isinstance (md , DeletedMetadata ):
1486
1483
# file has been deleted from remote
1487
- self . notify . send ( "{0} removed {1}" . format ( user_name , file_name ))
1484
+ change_type = "removed"
1488
1485
elif isinstance (md , FileMetadata ):
1489
1486
if self .get_local_rev (md .path_lower ):
1490
1487
is_new_file = False
1491
1488
else :
1492
1489
revs = self .client .list_revisions (md .path_lower , limit = 2 )
1493
1490
is_new_file = len (revs .entries ) == 1
1494
- if is_new_file :
1495
- # file has been added to remote
1496
- self .notify .send ("{0} added {1}" .format (user_name , file_name ))
1497
- else :
1498
- # file has been modified on remote
1499
- self .notify .send ("{0} changed {1}" .format (user_name , file_name ))
1491
+ change_type = "added" if is_new_file else "changed"
1492
+
1500
1493
elif isinstance (md , FolderMetadata ):
1501
- self .notify .send ("{0} added {1}" .format (user_name , file_name ))
1494
+ change_type = "added"
1495
+
1496
+ if user_name :
1497
+ self .notify .send ("{0} {1} {2}" .format (user_name , change_type , file_name ))
1498
+ else :
1499
+ self .notify .send ("{0} {1}" .format (file_name , change_type ))
1502
1500
1503
1501
elif n_changed > 1 :
1504
- # for multiple changes, display user name if all equal and type
1505
- # of change of "deleted"
1502
+ # for multiple changes, display user name if all equal
1506
1503
if all (isinstance (x , DeletedMetadata ) for x in changes .entries ):
1507
1504
change_type = "removed"
1508
1505
else :
0 commit comments