filecoin-project / slate

WIP - We're building the place you go to discover, share, and sell files on the web.
https://slate.host
MIT License
528 stars 67 forks source link

Cannot Update Tags via `api/v3/update-file` Endpoint #1154

Open sidnym-ladrut opened 1 year ago

sidnym-ladrut commented 1 year ago

Purpose

While other fields of a file can be modified through Slate's api/v3/update-file endpoint, the "tags" field remains seemingly immutable. The following is a demonstration in Python, which fails the last contained assertion (i.e. that the returned object after a successful POST has the same number of tags as the submitted object):

import requests
import json as JSON

headers = {
    "content-type": "application/json",
    "Authorization": "", # API key
}

r1 = requests.get(
    "https://slate.host/api/v3/get",
    headers=headers,
)
data = r1.json()
objs = data["collections"][0]["objects"]

mobj = objs[0]
mobj["tags"].append({
    "id": "", # Existing Tag ID
    "name": "", # Existing Tag Name
    "slatename": "", # Existing Tag Slate-name
})

r2 = requests.post(
    "https://slate.host/api/v3/update-file",
    headers=headers,
    json={"data": mobj},
)
assert r2.status_code == 200, "malformatted request"
nobj = r2.json()["file"]
assert len(nobj["tags"]) == len(mobj["tags"]), "update failed"

Deliverable

The tags field should be modifiable through the api/v3/update-file endpoint like the other file fields.

Dependencies

N/A