Check for auth on app first, and add error for 401 unauthorized
I just fission up'd the events directory, but because I have a handful of keys that I switch between, it failed at the end because I guess my loyal-short-sand-bat was owned by another one of my accounts.
We should check for auth first, THEN ipfs add everything, and THEN set the top level DAG CID.
Error message was 401, so it should be more like:
This account
USERNAMEdoesn't have access to upload to this appAPP-HAS-NAME
Debug failure at the bottom:
FailureResponse (Request {requestPath = (BaseUrl {baseUrlScheme = Https, baseUrlHost = "runfission.com", baseUrlPort = 443, baseUrlPath = ""},"/app/loyal-short-sand-bat.fission.app/QmfP5dFsxC1pMhBAniLdrC3FafKXjAJEJZLEd7njaw8Ngc"), requestQueryString = fromList [("copy-data",Just "true")], requestBody = Nothing, requestAccept = fromList [], requestHeaders = fromList [("Authorization","Bearer eyJ1YXYiOiIxLjAuMCIsImFsZyI6IkVkMjU1MTkiLCJjdHkiOm51bGwsInR5cCI6IkpXVCJ9.eyJwdGMiOiJBUFBFTkQiLCJuYmYiOjE1OTY3NTk0MTgsInJzYyI6eyJmbG9vZnMiOiIvIn0sImV4cCI6MTU5Njc1OTQ3OCwiaXNzIjoiZGlkOmtleTp6U3RFa3NEcnhrd1ltcHpxQmRBUWpqeDFQUmJIRzNmcTRDaEdlSmNZVVlVNDRhNENCVUV4VFRqZUNib3A2VXVyIiwicHJmIjpudWxsLCJhdWQiOiJkaWQ6a2V5OnpTdEVacHpTTXRUdDlrMnZzemd2Q3dGNGZMUVFTeUExNVc1QVE0ejNBUjZCeDRlRko1Y3JKRmJ1R3hLbWJtYTQifQ.ADK5iWG7a0wS5SGQJXT88u8H5P9MfmDLXOV7DECSVrsmWpwJfaKf1AsXZqQ7koTfQ3hFdmf_Qr7A9y5eQhJlAg")], requestHttpVersion = HTTP/1.1, requestMethod = "PATCH"}) (Response {responseStatusCode = Status {statusCode = 401, statusMessage = "Unauthorized"}, responseHeaders = fromList [("Date","Fri, 07 Aug 2020 00:17:29 GMT"),("Transfer-Encoding","chunked"),("Connection","keep-alive"),("Server","Warp/3.3.10")], responseHttpVersion = HTTP/1.1, responseBody = ""})
@(<unknown>:0:0)
🚫 Server unable to sync data
Doing this every time feels like overkill, but you're right that waiting for it to fail sucks. Here's a strategy:
- Read in the app's
fission.yaml - Look at
known_writersfield - If current DID is in the list, continue as normal. Otherwise:
- Attempt with
?dry_runflag set on HTTP request (would need to be implemented) - If response isn't a 2xx, report error to the user. Otherwise:
- Write DID to
known_writers - Continue as normal
Alternately to avoid leaking who has written to this app before, you can store the name of apps for the local machine in the global ~/.config/fission/config.yaml (❗ probably this actually version)