2021-04-04 19:52:19 +00:00
|
|
|
import { graphql, post, del } from '../api';
|
2021-05-15 01:49:27 +00:00
|
|
|
import { actorFields, releaseFields } from '../fragments';
|
2021-03-17 01:09:34 +00:00
|
|
|
import { curateUser } from '../curate';
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-19 02:27:48 +00:00
|
|
|
function initUsersActions(store, _router) {
|
2021-03-14 03:54:43 +00:00
|
|
|
async function fetchUser(context, username) {
|
2021-03-15 02:30:47 +00:00
|
|
|
const { user } = await graphql(`
|
|
|
|
query User(
|
2021-03-19 23:15:33 +00:00
|
|
|
$username: String!
|
2021-03-19 02:27:48 +00:00
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: Int
|
2021-03-15 02:30:47 +00:00
|
|
|
) {
|
|
|
|
user: userByUsername(username: $username) {
|
|
|
|
id
|
|
|
|
role
|
|
|
|
username
|
|
|
|
stashes {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
public
|
2021-03-21 02:23:58 +00:00
|
|
|
primary
|
2021-03-15 02:30:47 +00:00
|
|
|
actors: stashesActors {
|
|
|
|
comment
|
|
|
|
actor {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
gender
|
|
|
|
age
|
|
|
|
ageFromBirth
|
|
|
|
dateOfBirth
|
|
|
|
birthCity
|
|
|
|
birthState
|
|
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
|
|
alpha2
|
|
|
|
name
|
|
|
|
alias
|
|
|
|
}
|
|
|
|
avatar: avatarMedia {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
2021-03-21 16:23:15 +00:00
|
|
|
isS3
|
|
|
|
width
|
|
|
|
height
|
2021-05-15 20:16:42 +00:00
|
|
|
sfw: sfwMedia {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
isS3
|
|
|
|
width
|
|
|
|
height
|
|
|
|
}
|
2021-03-15 02:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-11 22:05:45 +00:00
|
|
|
scenes: stashesScenes(
|
|
|
|
first: 20
|
|
|
|
orderBy: CREATED_AT_DESC
|
|
|
|
) {
|
2021-03-15 02:30:47 +00:00
|
|
|
comment
|
|
|
|
scene {
|
2021-03-17 01:09:34 +00:00
|
|
|
${releaseFields}
|
2021-03-15 02:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-04 20:52:54 +00:00
|
|
|
alerts {
|
|
|
|
id
|
|
|
|
notify
|
|
|
|
email
|
2021-04-04 22:48:03 +00:00
|
|
|
stashes: alertsStashes {
|
|
|
|
stash {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
}
|
2021-04-04 20:52:54 +00:00
|
|
|
tags: alertsTags {
|
|
|
|
tag {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
actors: alertsActors {
|
|
|
|
actor {
|
|
|
|
${actorFields}
|
|
|
|
}
|
|
|
|
}
|
2022-01-24 21:29:27 +00:00
|
|
|
entity: alertsEntity {
|
2021-04-04 20:52:54 +00:00
|
|
|
entity {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
2021-04-04 22:48:03 +00:00
|
|
|
type
|
2021-04-04 20:52:54 +00:00
|
|
|
independent
|
2021-04-04 22:48:03 +00:00
|
|
|
hasLogo
|
2021-04-04 20:52:54 +00:00
|
|
|
parent {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
2021-04-04 22:48:03 +00:00
|
|
|
type
|
2021-04-04 20:52:54 +00:00
|
|
|
independent
|
2021-04-04 22:48:03 +00:00
|
|
|
hasLogo
|
2021-04-04 20:52:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-15 01:49:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
hasAuth: !!store.state.auth.user,
|
|
|
|
userId: store.state.auth.user?.id || null,
|
|
|
|
username,
|
|
|
|
});
|
2021-03-14 03:54:43 +00:00
|
|
|
|
2021-03-17 01:09:34 +00:00
|
|
|
return curateUser(user);
|
2021-03-14 03:54:43 +00:00
|
|
|
}
|
|
|
|
|
2021-04-04 19:52:19 +00:00
|
|
|
async function addAlert(context, alert) {
|
|
|
|
return post('/alerts', alert);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function removeAlert(context, alertId) {
|
|
|
|
return del(`/alerts/${alertId}`);
|
|
|
|
}
|
|
|
|
|
2021-03-14 03:54:43 +00:00
|
|
|
return {
|
2021-04-04 19:52:19 +00:00
|
|
|
addAlert,
|
2021-03-14 03:54:43 +00:00
|
|
|
fetchUser,
|
2021-04-04 19:52:19 +00:00
|
|
|
removeAlert,
|
2021-03-14 03:54:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default initUsersActions;
|