How to store an encoded variable for each owner of an NFT that only they can decode? - encoding

Let's say for example we want to store a URL on chain for that specific NFT but we do not want anyone else to be able to see the URL.
We can have a function in the contract that asks for an ID and firstly can only be called by the owner of that particilar NFT ID but will secondly be able to decode the URL we stored for it.

Related

How to pass user id

Suppose super admin wants to see another sub admin's details
my current method is GET -- domain/api/user/get_by_id/{id}
I'm using JWT also.
is my method correct?? Is there any other method where I don't put the id directly in URL
my current method is GET -- domain/api/user/get_by_id/{id}
So, answering your questions one by one,
is my method correct??
If you are using RESt Web services as you have added that tag, then no, this should not be the url. I would suggest you to read upon REST web services a little as the url should look somewhat like this.
GET -- domain/api/user/{id}
Also the id you put in url is a public one and not the one of your database. So a entry in the database should look like:
Id | Username | userId (it is public)
1 | debabrata| r1398fh9238yhas89
So to call the url r1398fh9238yhas89 will be passed and not 1.
Is there any other method where I don't put the id directly in URL
You could encode the id in base64, jwt style or some kind of other encryption or as earlier stated just send a public ID which doesn't mean anything for your database.

REST: nested resource url when you don't want the parent ID visible

I read that the route for getting a nested resource in REST should look like this
/articles/:articleId/comments
The owner (:articleId) of the child resource will be visible.
But what if you have an owner that you don't want the client to know about?
For example, let's say I have an app where users have anonymous posts. I wouldn't want other users to see the client fetching the post by /users/123/post/321 because users could identify who wrote the post from the id and it wouldn't be anonymous.
Is the id necessary? Is it ok to instead do /users/posts/321 if all posts have a unique id?
There are no actual requirements for the URL format. It can be whatever you'd like it to be.
If it were me, I would use simply /posts/321 and leave users out of it, since a particular user isn't specified in your URL at all. I think that's the clearest way to handle it in your case.

Retriving the attachment's address,which is encoded in base64 from odoo 12 database(postgres)

I have a web app and i need to display an image whose address is stored in odoo database(postgre) and is encoded in base64.
Can anyone help me in how i can decode the data and get the link.
Below is an example.
The data is like this in the database
I want to decode the data to get the url which look like this:
The paths for partner image in v12 are:
/web/image?model=res.partner&field=image_medium&id=partner_id&unique=nonce
/web/image/res.partner/partner_id/image_name?unique=nonce
Where:
partner_id is the id of the partner in Odoo database.
nonce is optional, is used to avoid cache and can be current timestamp.
partner_name can be anything
The problem with this urls is that public or portal users can't access any partner data by default for privacy reasons except from themselves (including the image). Depending on your case, some solutions could be:
If you aren't concerned about privacy issues, install website_partner module, publish partners one by one, and the urls will return the real image.
create a module with a controller that delivers only the partner image using sudo().

Linkedin API get public-profile

I am trying to get the id from the public-profile-url. The query looks like:
https://api.linkedin.com/v1/people/url={https://www.linkedin.com/in/name}
However, what I get get back from linkedin is:
<error>
<status>400</status>
<timestamp>1460131755319</timestamp>
<request-id>2OV9FJ0DTR</request-id>
<error-code>0</error-code>
<message>[invalid.param.url]. Public profile URL is not correct,
{url=}; should be {https://www.linkedin.com/pub/[member-name/]x/y/z} or
{https://www.linkedin.com/in/string}</message>
The interesting part is:
Public profile URL is not correct, {url=}; should be {https://www.linkedin.com/pub/[member-name/]x/y/z} or {https://www.linkedin.com/in/string}
The url clearly adheres to the rules that they mention and the url works. Any idea on how to fix it?
You cannot reliably retrieve a member ID from a profile URL. id values that you can rely on are returned as part of Profile API calls. From time to time, LinkedIn changes the format of it's public profile URLs, so attempting to parse them or reconstruct them can leave your app in a broken state. The public-profile-url field should be considered read-only, and not something you try and parse or create yourself.
e.g.: GET https://api.linkedin.com/v1/people/~:(id,first-name,last-name,public-profile-url)?format=json
id values are encoded to specific LinkedIn applications and cannot be re-used between apps. As a result, any value you attempt to pull out of a URL won't be of any use to you. The information needs to be acquired via an API call.

Displaying each user's profile picture from Parse in their respective tableview cells (Swift and Parse)

I am trying to display the profile picture of the author for each post in the tableview using Swift and Parse.
The view controller at hand is querying one class (Post class) from Parse to obtain all the contents of a post. However, only one of the contents of a post (the profile picture which is of type File in Parse) is stored in another class, the User class, because each user has a profile picture.
Each post in the Post class has a foreign key (to represent the author of the post) which points to the User class.
How can I access the photo column from the User class from a pointer in the Post class?
The reference from the post to a user should be a pointer. Then, the query can specify to includeKey with the name of that pointer to have the user included in the results of the query so you can access its details.
The above requires public read permissions on all users. If you want better data security you need to do the above in cloud code and return only the required data.