Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

tritnguyen's avatar
tritnguyen
Explorer | Level 3
4 years ago
Solved

How to keep track a list of active team members.

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.

 

  • 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".

2 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    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".

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!