Closed riazaia closed 2 years ago
Thoughts:
From the discord:
Array<type>
notationI saw a point brought up on Twitter that the Array
So we should use:
author: Array<
| "Anonymous"
| {
username: string;
pseud: string;
}>;
I think it's worth doing (note that I don't remember exactly how orphan works):
const ORPHAN_ACCOUNT = { username: "orphan", pseud: "orphan" } as const;
// ...
author: Array<
| "Anonymous"
| typeof ORPHAN_ACCOUNT
| {
username: string;
pseud: string;
}>;
whenever we return an orphan account, we should make sure to return the ORPHAN_ACCOUNT object, so people can do stuff like:
if (account.author == ORPHAN_ACCOUNT) {
// TODO: do something with orphan account
}
something else we could do is make the executive decision of also doing:
const ANONYMOUS_ACCOUNT = { username: "anonymous", pseud: "anonymous" } as const;
const ORPHAN_ACCOUNT = { username: "orphan", pseud: "orphan" } as const;
author: Array<
| typeof ANONYMOUS_ACCOUNT
| typeof ORPHAN_ACCOUNT
| {
username: string;
pseud: string;
}>;
it's not 100% correct because anonymous account doesn't have a pseud, but also if we go the other direction people will have to always check that the account is not anonymous before accessing username or pseud, which is going to get annoying fast.
so, like, everything would have to be:
if (author == "Anonymous") {
// special case
} else {
// Without the previous check TS would yell at you here
const { username, pseud } = author;
// do stuff for all other users
}
vs
// You can just do this wherever you have an author without worrying about the Anonymous case
const { username, pseud } = author;
which you could argue is going to force people to special case for anonymous so they aren't caught by surprise by it, but also IDK, I kinda hate having to type narrow a lot.
We can discuss all this on discord then summarize our decisions here.
Works themselves are anonymized (by being put in an anonymous collection), not the authors. What happens when a work is added to a collection is that all the authors become hidden under a single string, "Anonymous"
. i.e. an anonymous work with 1 author will say Title by Anonymous
, and so will an anonymous work with 3 authors.
The previously suggested typing implies returns like authors: ["Anonymous", "Anonymous", "Anonymous"]
or ["Anonymous", {username: "cool_user", pseud: "cool_user"}]
are possible when they're not.
There's also an AO3 user with the username of Anonymous
, so username: Anonymous
for anonymized works would be incorrect.
Users can also create pseuds called Anonymous. e.g. Title by Anonymous (Username)
would result in the object: {username: Username, pseud: Anonymous}
.
In regards to the possibility of returning null
or an empty array when a work is anonymous: it might be okay for experienced developers, but less experienced ones might not think to do something with an empty array.
There could probably be an isAnonymousWork
utility method added.
When you orphan your fanworks you have the option to have your pseuds remain or not. This means that while some works do have an author with the shape of {username: orphan_account, pseud: orphan_account}
, others will have pseuds we should grab.
The only difference between in practice between a regular user's account and orphan_account is that the latter's profile can't be reached. An isOrphanAuthor
or isOrphanAccount
method should be added.
const isOrphan = (author: Author) => author.username == "orphan_account";
interface Author {
username: string;
pseud: string;
}
interface WorkSummary {
// ...
authors: "Anonymous" | Author[]
}
The changes are as follows:
Remove the
id
property, since the methodgetWorksPage
uses the id as a parameter in order to return the work summary, so that seems redundant? We discussed in the past whether we should use the URL or the workId for extracting the info, and we decided on id. Link to that discussionA work with multiple authors in an anonymous collection will only display one single string value,
"Anonymous"
in the author field, so I edited the union type to reflect that. I also removed"orphan_account"
since in practice it simply shows up as an (inaccessible) username, and pseuds are displayed like normal. For example: PseudyPseud (orphan_account), with a URL ofhttps://archiveofourown.org/users/orphan_account/pseuds/PseudyPseud
(which results in a 404). It seems like it's not ideal to lose the pseud info on orphaned works.Moved the
complete
property out of thechapters
section, since I think having both Published and Complete there can be confusing, and complete refers to the work itself anyway.