Control the Activity of a shared folder in Drive - node.js

I would like to control the activity of a shared folder that I have in Google Drive.
I am using the Google Drive Activity API to see the real-time information of the files but I came across two problems:
I can only see the modifications in the folder made by me and not by the others. (I suppose there's something about the 2AuthClient token)
I can't get to know if a file was renamed or not (which is not that important at the moment)
I was thinking that maybe a solution would be to ask that each account that has access to the folder to create an Auth2Client token and send it to me. After that run a function for each person who sends their token, the problem I see with that is the simple act of sharing a token which is personal and private but also the fact of doing multiple functions with the same code inside is not very logical.
Has anyone faced the same problem and found a solution?
My code is from the Developpers Google platform: here
And even if in the code it's supposed to get the ActorInfo, it only gives me as the actor because it only sees my modifications and not the other modifications.
Or even if someone knows another way to achieve this task (maybe without google drive activity API) it will be very helpfull. Thanks in advance!

To show the activities to determined resources you have to add one of the following parameters as a union field key: itemName or ancestorName. The default is ancestorName : items/root if no key is specified
As stated in the documentation:
Fields
itemName
string
Return activities for this Drive item. The format is items/ITEM_ID.
ancestorName
string
Return activities for this Drive folder and all children and descendants. The format is items/ITEM_ID.
In your case, as you want to query for a determined shared folder, you should add this inside the Request Body:
const param = {"ancestorName" : "items/<folder_id>"}
Documentation:
Node.js driveactivity library
Activity query

Related

Getting a list of BuildFire plugin users from the Widget side

I am developing a plugin that allows the user the post content that I am storing in an object in publicData. To identify the user that posted the data, I am storing the _id that is returned from buildfire.auth.getCurrentUser() in that publicData object along with the content of the post.
Is there a way I can access a list of the users of my plugin, then iterate through that to find the user with the corresponding _id? A list of the users of my plugin must exist somewhere, I just do not know how to/if I can access it.
Any help on this would be greatly appreciated!
I would recommend caching the user object's nonsensitive data. Remember, you have a bit more access to the logged-in user over fetching another user profile using the user id. https://github.com/BuildFire/sdk/wiki/How-to-use-Auth#buildfireauth-getuserprofileoptionscallback
Since the user profile picture URL is really an API, you don't have to worry about the user changing it since it will always return the latest. The other property I recommend you cache is the Display name (not the first name and last name) since that rarely changes as well. This way your performance wont suffer and you can do a lazy fetch for a distinct list of user ids an update them as needed. KNowing most wont need an UI updates since nothing changed

Get user performing action in Sharepoint CSOM

We are using SharePoint client object model (CSOM) and REST/OData endpoints to retrieve/manage data on sharepoint.
Is there anyway to get information on the user performing the MOVE on a file (for example, move file from folder A to folder B within same site collection)? When I use this REST API call before and after the move, Author and Editor remains the same even though a completely different user moved the file from folder A to folder B. SPChangeItem does not seem to have any members with this information either.
https://{site_url}/_api/web/GetFileByServerRelativePath(DecodedUrl=#fileUrl)?$expand=Author,ListItemAllFields,ListItemAllFields/ParentList,ListItemAllFields/ParentList/ParentWeb&$select=UniqueId,Author/LoginName,Author/Email,Author/Id,Editor/LoginName,Editor/Email,Name,UserName,ServerRelativeUrl,MajorVersion,MinorVersion,Length,ListItemAllFields&#fileUrl={url_encoded_file_path}
Is there anyway to get logged in user while using REST API?
When I use this REST API call, Id returned is the user corresponding to Bearer accesstoken.
https://{site_url}/_api/Web/CurrentUser?$select=Id
When moving a file to another folder, the metadata including author/editor is remained the same one, what changed is only the location. This is by designed.
If we want to know the user who performed this operation, we could check the version events of the file as it will immediately prompt an modification event when moving a file.
FileVersionEvent
Rest API endpoint:
_api/Web/GetFileByServerRelativePath('filepath')/VersionEvents
Thanks

Spring Data Rest Frontend deep linking

So i have been struggling with this one question some time now:
How to handle details Page or deep linking on the Frontend.
So, say, we got a paged collection endpoint with user entities in it and a React App consuming the endpoint.
The flow would be, user authenticates, gets collections, clicks on an item and is either:
Redirected to a new Url say: webapp.com/users/userid
A modal opens with the user details.
Say we got a scenario were two people working with the webapp, Person 1 wants to share a link with Person 2. Person 2 should do some updates on a specific user, which is identified by the link.
The link should be something like : https://www.webapp.com/users/{slug or id}
With Option 2 this functionality is not mappable.
With Option 1 we got to expose the ids in the response to identify the resource, which may work, but we would still need to hardcode the url, as the findById method is not exported as a Uri Template.
So, my Solution would be to add a slug for the resources, implement a search method by the slug, and then get the user, if found, by its self-link.
Sounds like a good solution for me, but on the other hand, I would have to add an extra frontend id(the slug here) which would need to be also unique, to the database model.
So how do you guys handle a problem like this, or is there anybody using spring data rest in this way or in production mode where you have the handle situations like this?
Should mention that this isn’t a primary problem with spring data rest but rather with hateoas itself.
thanks in advance
Florian
You don't need to hardcode URL template. Spring data rest will generate links for each resource.
You can refer to it from front end by some format like: {your_user_object}._links.self.href

Google Docs Folder Not Found

We are using Document List API version 3. We use two-legged OAuth and get access using permission obtained through Google Apps Marketplace. We retrieve a list of folders contained in a folder as follows:
https://docs.google.com/feeds/default/private/full/folder:[folder doc id]/contents/-/folder?xoauth_requestor_id=[user name]
We get 9 results. We retain the document ids of these folders. Later on we retrieve each folder using their document id as follows where [user name] is the same as what we used previously:
https://docs.google.com/feeds/default/private/full/[folder doc id]?xoauth_requestor_id=[user name]
We are able to get the document (folder) for 8 of the 9 but for one of them we get ResourceNotFoundException no matter when we try and no matter if we retry. We know that the folder still exists and the specified user has access to it.
This is similar in nature to the issue that someone else reported recently in:
Document not found
Is this likely to be a google bug? Any suggestions of how to resolve it other than moving to Google Drive API?
Regards,
LT
How long are you holding onto those document IDs (or really, the contentSrc URL)? I've found that those things can expire after a few hours so you should not cache them for any length of time.

How to know if the SPUser is a "real" user or a system user like "search"?

I have built an http module that detect file openings. I don't want any alert to be raised when the file is crawled by a system account like 'search' for instance. I have tried to use isApplicationPrincipal and several others but it didn't work.
How would you do to keep only track of "real" users modifications ?
Thank you
The SharePoint search index crawler uses "Robot-something" as HTTP user agent. I don't know what the exact string look like, sorry for that.
You can check if the HttpRequest.UserAgent property contains "Robot":
if (HttpContext.Current.Request.UserAgent.IndexOf("Robot", StringComparison.OrdinalIgnoreCase) == -1)
{
// Code that runs for real users only.
}
Have you tried to use SharePoint Audits? They create a report when a user opens a file. And they are able to track file openings not only in the web site but in clients applications too.

Resources