cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to keep track a list of active team members.

How to keep track a list of active team members.

tritnguyen
Explorer | Level 3
Go to solution

Hi All,

 

I have a Business Advance Account. I want to keep track a list of active members of my team. So I have the following code to list all my team members; it works fine. 

 

static public  void getUsers(DbxTeamTeamRequests team)
{
try
{
MembersListResult memberList = team.membersList();
memberCursor = memberList.getCursor();

while(true)
{
List<TeamMemberInfo> members = memberList.getMembers();
for(int i = 0; i < members.size(); i++)
{
TeamMemberInfo member = members.get(i);
System.out.println(member.toStringMultiline());
}

if(memberList.getHasMore())
{
try{
memberList = team.membersListContinue(memberCursor);
memberCursor = memberList.getCursor();
}
catch (DbxException e){
e.printStackTrace();
}
}
else
{
break;
}
}
}
catch (DbxException e)
{
throw new RuntimeException(e);
}
}

//

However I want to update the list in the interval of 5 minutes. So I have the thread that wakes up in every 5 minutes and run this code:

static public void getMemberLogEvents(DbxTeamTeamLogRequests teamLog)
{
GetTeamEventsResult eventRes = null;
try
{
eventRes = teamLog.getEvents(); //Connect and get events from DropBox server.
eventCursor = eventRes.getCursor();
}
catch (DbxException e1)
{
e1.printStackTrace();
}
while(true)
{
List<TeamEvent> events = eventRes.getEvents();
for(int i = 0; i < events.size(); i++)
{
TeamEvent event = events.get(i);
if(event.getEventCategory() == MEMBERS && event.getEventType().tag() == MEMBER_CHANGE_STATUS)
{
if(event.getDetails().getMemberChangeStatusDetailsValue().getNewValue() == ACTIVE){
//Add to the member list.
}
else if(event.getDetails().getMemberChangeStatusDetailsValue().getNewValue() == REMOVED){
//Remove from member list by member ID.
}
}
}

if(eventRes.getHasMore())
{
try
{
eventRes = teamLog.getEventsContinue(eventCursor);
eventCursor = eventRes.getCursor();
}
catch (DbxException e)
{
e.printStackTrace();
}
}
else
{
break;
}
}
}


Is it a right approach? Because sometimes I got REMOVE event to the user but that user did not have a ACTIVE event. Hence, it messes up the member list.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

You can certainly monitor the event log for member changes like this. Note that not all members will necessarily become "active" though, so you may see a member "removed" without being "active" first. That can happen if a member account is "invited" and then removed before they actually set up the account. In that case the account would never become "active". You may want to check for "invited" instead of "active".

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

You can certainly monitor the event log for member changes like this. Note that not all members will necessarily become "active" though, so you may see a member "removed" without being "active" first. That can happen if a member account is "invited" and then removed before they actually set up the account. In that case the account would never become "active". You may want to check for "invited" instead of "active".

tritnguyen
Explorer | Level 3
Go to solution

Thank you for the information.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    tritnguyen Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?