Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete obsolete code #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/schema/elba.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const typeDef = `
ERROR_AGENCY_NOT_SUBSCRIBED
ERROR_INVALID_PICKUP_BRANCH
ERROR_PID_NOT_RESERVABLE
ERROR_NO_NAME_OR_EMAIL
ERROR_NO_MUNICIPALITY
}

type CopyRequestResponse {
Expand Down Expand Up @@ -98,14 +100,14 @@ export const resolvers = {
// Ensure a pair of email and name can be set
if (!((userName || user.name) && (userMail || user.mail))) {
return {
status: "ERROR_UNAUTHENTICATED_USER",
status: "ERROR_NO_NAME_OR_EMAIL",
};
}

// Ensure user has municipalityAgencyId
if (!user.municipalityAgencyId) {
return {
status: "ERROR_UNAUTHENTICATED_USER",
status: "ERROR_NO_MUNICIPALITY",
};
}

Expand Down Expand Up @@ -138,7 +140,6 @@ export const resolvers = {
}

// Then send order

return await context.datasources
.getLoader("statsbiblioteketSubmitArticleOrder")
.load({
Expand Down
97 changes: 0 additions & 97 deletions src/schema/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ type Query {

type Mutation {
data_collect(input: DataCollectInput!): String!
submitPeriodicaArticleOrder(input: PeriodicaArticleOrder!, dryRun: Boolean): PeriodicaArticleOrderResponse!
submitOrder(input: SubmitOrderInput!): SubmitOrder
submitSession(input: SessionInput!): String!
deleteSession: String!
Expand Down Expand Up @@ -314,102 +313,6 @@ export const resolvers = {

return "OK";
},
async submitPeriodicaArticleOrder(parent, args, context, info) {
let { userName, userMail } = args.input;

// Fetch and check existence of branch
const digitalAccessSubscriptions = await context.datasources
.getLoader("statsbiblioteketSubscribers")
.load("");

const infomediaSubscriptions = await context.datasources
.getLoader("idp")
.load("");

const branch = (
await context.datasources.getLoader("library").load({
branchId: args.input.pickUpBranch,
digitalAccessSubscriptions,
infomediaSubscriptions,
})
).result[0];

if (!branch) {
return {
status: "ERROR_INVALID_PICKUP_BRANCH",
};
}

const hasBorrowerCheck = await resolveBorrowerCheck(
branch.agencyId,
context
);

// If branch has borrowerCheck, we require the user to be authenticated via that agency
if (hasBorrowerCheck) {
if (!context.smaug || !context.smaug.user || !context.smaug.user.id) {
return {
status: "ERROR_UNAUTHORIZED_USER",
};
}
const agencyId = context.smaug.user.agency;
if (branch.agencyId !== agencyId) {
return {
status: "ERROR_INVALID_PICKUP_BRANCH",
};
}

// We need users name and email
const user = await context.datasources.getLoader("user").load({
accessToken: context.accessToken,
});
userName = user.name ? user.name : userMail;
userMail = user.mail ? user.mail : userMail;
}

if (!userName || !userMail) {
return {
status: "ERROR_NO_NAME_OR_EMAIL",
};
}

// Agency must be subscribed
const subscriptions = await context.datasources
.getLoader("statsbiblioteketSubscribers")
.load("");
if (!subscriptions[branch.agencyId]) {
return {
status: "ERROR_AGENCY_NOT_SUBSCRIBED",
};
}

// Pid must be a manifestation with a valid issn (valid journal)
let issn;
try {
const onlineAccess = await resolveAccess(args.input.pid, context);
issn = onlineAccess.find((entry) => entry.issn);
} catch (e) {
return {
status: "ERROR_PID_NOT_RESERVABLE",
};
}
if (!issn) {
return {
status: "ERROR_PID_NOT_RESERVABLE",
};
}

// Then send order
const res = await context.datasources
.getLoader("statsbiblioteketSubmitArticleOrder")
.load({
...args.input,
agencyId: branch.agencyId,
dryRun: args.dryRun,
});

return res;
},
async submitOrder(parent, args, context, info) {
const digitalAccessSubscriptions = await context.datasources
.getLoader("statsbiblioteketSubscribers")
Expand Down