Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share GPX #978

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Share GPX #978

wants to merge 4 commits into from

Conversation

alisa911
Copy link
Contributor

No description provided.

@alisa911
Copy link
Contributor Author

@alisa911
Copy link
Contributor Author

API list

  • generate url - /generate-shared-url
  • get gpx by url - /gpx/share/{token}
  • get users with access - /accessed-users
  • create blacklist - /create-file-blacklist
  • get backlist - /get-blacklist

@alisa911
Copy link
Contributor Author

Screenshot 2024-11-20 at 16 52 26

@alisa911
Copy link
Contributor Author

Screenshot 2024-11-20 at 16 53 13

@alisa911
Copy link
Contributor Author

Screenshot 2024-11-20 at 16 53 40

@alisa911
Copy link
Contributor Author

Screenshot 2024-11-20 at 16 54 12

@alisa911
Copy link
Contributor Author

Screenshot 2024-11-20 at 16 54 41

@@ -833,4 +828,112 @@ public String getRegionsByLatlon(@RequestParam("lat") double lat, @RequestParam(
regions = osmandRegions.getRegionsToDownload(lat, lon, regions);
return gson.toJson(Map.of("regions", regions));
}

@GetMapping(path = {"/generate-shared-url"}, produces = "application/json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a new API group for sharing, i.e. /share/get /share/generate /share/accessed-users, etc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 url is enough, how access is provided is just a single string type. Other apis to edit blacklist whitelist should be provided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better naming:
/file-share - always with POST !

Copy link
Contributor Author

@alisa911 alisa911 Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 url is enough - what do you mean?

return ResponseEntity.ok(gson.toJson(Map.of("sharedUrl", sharedUrl)));
}

@GetMapping(path = {"/gpx/share/{token}"}, produces = "application/json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/share/get/{token}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's token?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generated unique code to create the shared url
b0244cbc06abda8c69b83722315a for url https://osmand.net/map/gpx/share/b0244cbc06abda8c69b83722315a
It is stored in user_files

return ResponseEntity.ok("Blacklist created");
}

@GetMapping(path = {"/get-blacklist"}, produces = "application/json")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method get file shared information is enough with all information of json. No secrets could be to the owner of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean. This is api for showing the list to the user.

@alisa911
Copy link
Contributor Author

Screenshot 2024-11-21 at 12 38 41

@alisa911
Copy link
Contributor Author

shared_info
{"blacklist": {"users": [9, 15]}, "whitelist": {"permissions": {"13": {"permissionType": "READ"}}}, "accessedUsers": {"users": [19]}}
shared_code
7e3ebd26-5a2f-49a1-b9ba-9f0e80447cdd

Iterable<UserFile> findAllByUserid(int userid);


UserFile findUserFileBySharedCode(String code);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db index?

@alisa911
Copy link
Contributor Author

API list

/file-share - create and save code, return url
/share/gpx/{code} - get file by url
/share/accessed-users - get users with access
/share/edit-blacklist
/share/edit-whitelist
/share/get-blacklist

}

public static class AccessedUsers {
private Set<Integer> users;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map<Integer, Long> - timestamp of first access

@@ -833,4 +832,128 @@ public String getRegionsByLatlon(@RequestParam("lat") double lat, @RequestParam(
regions = osmandRegions.getRegionsToDownload(lat, lon, regions);
return gson.toJson(Map.of("regions", regions));
}

// Share GPX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Share controller needed with own url /share

@vshcherb
Copy link
Member

vshcherb commented Nov 21, 2024

API Editor

  • /share/generate-link?file=&filetype=&type= - create and save code, return url
  • /share/edit-blacklist -
  • /share/edit-whitelist -
  • /share/get-shared-info - (full json from db with integer replaced by users)

Link
https://osmand.net/map/?share=UNIQUE_CODE.

API Get access:

  • /share/check-access?share=UNIQUE_CODE. - returns how access could be and whether you have access or not (if logged in)
  • /share/get?share=UNIQUE_CODE.

/share/get-gpx

public enum PermissionType {
READ,
WRITE,
EXECUTE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXECUTE - execute what and where?

Comment on lines +851 to +852
String domain = request.getScheme() + "://" + request.getServerName() +
(request.getServerPort() != 80 && request.getServerPort() != 443 ? ":" + request.getServerPort() : "");
Copy link
Contributor

@RZR-UA RZR-UA Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to not use OsmAnd Server Name/Port in the URL. The URL should exclude domain/port and should be processed on the Client (Web - relative to URL of current site, Android - fixed osmand.net/..., etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants