Basic code added for sending quizs.
TODO: check quiz is valid, it hasn't been responded yet, and is owned by the actor responding + create Note with the response for activitypub + create federation INBOX event for parsing responses
This commit is contained in:
parent
034963b258
commit
f00aa6d9d8
|
@ -116,6 +116,10 @@ module.exports = {
|
||||||
return res.json({ error: 'unknown_error' })
|
return res.json({ error: 'unknown_error' })
|
||||||
return res.json(data)
|
return res.json(data)
|
||||||
}],
|
}],
|
||||||
|
post: [auth.enforceSession, async (req, res) => {
|
||||||
|
console.log(req.body)
|
||||||
|
return res.json({})
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
pending_follows: {
|
pending_follows: {
|
||||||
get: [auth.enforceSession, async (req, res) => {
|
get: [auth.enforceSession, async (req, res) => {
|
||||||
|
|
|
@ -68,7 +68,9 @@ app.on('apex-inbox', activity.federation.inbox)
|
||||||
/* POST */ app.route(api.v1('/auth/login')).post(api.auth.login.post)
|
/* POST */ app.route(api.v1('/auth/login')).post(api.auth.login.post)
|
||||||
/* GET */ app.route(api.v1('/feed/meet')).get(api.feed.meet.get)
|
/* GET */ app.route(api.v1('/feed/meet')).get(api.feed.meet.get)
|
||||||
/* GET */ app.route(api.v1('/me/pending_follows')).get(api.me.pending_follows.get)
|
/* GET */ app.route(api.v1('/me/pending_follows')).get(api.me.pending_follows.get)
|
||||||
/* GET */ app.route(api.v1('/me/quizs')).get(api.me.quizs.get)
|
/* ALL */ app.route(api.v1('/me/quizs'))
|
||||||
|
.get(api.me.quizs.get)
|
||||||
|
.post(api.me.quizs.post)
|
||||||
/* POST */ app.route(api.v1('/accounts/follow')).post(api.accounts.follow.post)
|
/* POST */ app.route(api.v1('/accounts/follow')).post(api.accounts.follow.post)
|
||||||
/* POST */ app.route(api.v1('/accounts/unfollow')).post(api.accounts.unfollow.post)
|
/* POST */ app.route(api.v1('/accounts/unfollow')).post(api.accounts.unfollow.post)
|
||||||
/* POST */ app.route(api.v1('/accounts/block')).post(api.accounts.block.post)
|
/* POST */ app.route(api.v1('/accounts/block')).post(api.accounts.block.post)
|
||||||
|
|
|
@ -157,7 +157,18 @@ app.pages.quiz = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
send: function() {
|
send: function() {
|
||||||
console.log('SEND');
|
const form = document.querySelector('form#quiz');
|
||||||
|
var data = { quiz_id: page().data.id };
|
||||||
|
for (var i = 0; i < page().data.content.length; i++) {
|
||||||
|
const key = 'question_'+page().data.content[i].index;
|
||||||
|
const value = form[key].value.trim();
|
||||||
|
if (value === '')
|
||||||
|
return app.toast.error('TODO: translate: you must fill all quiz questions before sending it');
|
||||||
|
data[key] = value;
|
||||||
|
}
|
||||||
|
http.post('/api/v1/me/quizs', data, function(json) {
|
||||||
|
console.log(json);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue