Fixed issue where the user was not being saved alongside the request. Also fixed what the list of requests are sorted by.
This commit is contained in:
@@ -16,8 +16,8 @@ class RequestRepository {
|
|||||||
constructor(cache, database) {
|
constructor(cache, database) {
|
||||||
this.database = database || establishedDatabase;
|
this.database = database || establishedDatabase;
|
||||||
this.queries = {
|
this.queries = {
|
||||||
insertRequest: "INSERT INTO requests VALUES (?, ?, ?, ?, ?, ?, ?, CURRENT_DATE, 'requested', ?, ?)",
|
insertRequest: "INSERT INTO requests VALUES (?, ?, ?, ?, ?, ?, ?, DEFAULT, DEFAULT, ?, ?)",
|
||||||
fetchRequestedItems: 'SELECT * FROM requests ORDER BY requested_by ASC',
|
fetchRequestedItems: 'SELECT * FROM requests ORDER BY date ASC',
|
||||||
fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ?',
|
fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ?',
|
||||||
updateRequestedById: 'UPDATE requests SET status = ? WHERE id is ? AND type is ?',
|
updateRequestedById: 'UPDATE requests SET status = ? WHERE id is ? AND type is ?',
|
||||||
checkIfIdRequested: 'SELECT * FROM requests WHERE id IS ? AND type IS ?',
|
checkIfIdRequested: 'SELECT * FROM requests WHERE id IS ? AND type IS ?',
|
||||||
@@ -68,7 +68,7 @@ class RequestRepository {
|
|||||||
tmdb.lookup(identifier, type).then((movie) => {
|
tmdb.lookup(identifier, type).then((movie) => {
|
||||||
if (user === 'false') { user = 'NULL'; }
|
if (user === 'false') { user = 'NULL'; }
|
||||||
// Add request to database
|
// Add request to database
|
||||||
this.database.run(this.queries.insertRequest, [movie.id, movie.title, movie.year, movie.poster_path, movie.background_path, user, ip, user_agent, movie.type]);
|
this.database.run(this.queries.insertRequest, [movie.id, movie.title, movie.year, movie.poster_path, movie.background_path, user.username, ip, user_agent, movie.type]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function submitRequestController(req, res) {
|
|||||||
const type = req.query.type;
|
const type = req.query.type;
|
||||||
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
const user_agent = req.headers['user-agent'];
|
const user_agent = req.headers['user-agent'];
|
||||||
const user = req.headers.loggedinuser;
|
const user = req.headers.loggedInUser;
|
||||||
|
|
||||||
requestRepository.sendRequest(id, type, ip, user_agent, user)
|
requestRepository.sendRequest(id, type, ip, user_agent, user)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user