Update Story apis, move FE to v0 and add v1 for oauth clients

This commit is contained in:
Daniel Supernault 2020-02-04 21:04:58 -07:00
parent e2828f4b85
commit 92654fabdc
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
8 changed files with 23 additions and 14 deletions

View file

@ -680,6 +680,7 @@ export default {
let self = this; let self = this;
self.status = response.data.status; self.status = response.data.status;
self.user = response.data.user; self.user = response.data.user;
window._sharedData.curUser = self.user;
self.media = self.status.media_attachments; self.media = self.status.media_attachments;
self.reactions = response.data.reactions; self.reactions = response.data.reactions;
self.likes = response.data.likes; self.likes = response.data.likes;

View file

@ -642,7 +642,7 @@
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
this.user = res.data; this.user = res.data;
if(res.data.id == this.profileId || this.relationship.following == true) { if(res.data.id == this.profileId || this.relationship.following == true) {
axios.get('/api/stories/v1/exists/' + this.profileId) axios.get('/api/stories/v0/exists/' + this.profileId)
.then(res => { .then(res => {
this.hasStory = res.data == true; this.hasStory = res.data == true;
}) })

View file

@ -177,7 +177,7 @@
mounted() { mounted() {
this.mediaWatcher(); this.mediaWatcher();
axios.get('/api/stories/v1/fetch/' + this.profileId) axios.get('/api/stories/v0/fetch/' + this.profileId)
.then(res => this.stories = res.data); .then(res => this.stories = res.data);
}, },
@ -226,7 +226,7 @@
} }
}; };
axios.post('/api/stories/v1/add', form, xhrConfig) axios.post('/api/stories/v0/add', form, xhrConfig)
.then(function(e) { .then(function(e) {
self.uploadProgress = 100; self.uploadProgress = 100;
self.uploading = false; self.uploading = false;
@ -264,7 +264,7 @@
return; return;
} }
axios.delete('/api/stories/v1/delete/' + story.id) axios.delete('/api/stories/v0/delete/' + story.id)
.then(res => { .then(res => {
this.stories.splice(index, 1); this.stories.splice(index, 1);
if(this.stories.length == 0) { if(this.stories.length == 0) {

View file

@ -30,7 +30,7 @@
methods: { methods: {
fetchStories() { fetchStories() {
axios.get('/api/stories/v1/recent') axios.get('/api/stories/v0/recent')
.then(res => { .then(res => {
let data = res.data; let data = res.data;
let stories = new Zuck('storyContainer', { let stories = new Zuck('storyContainer', {
@ -57,7 +57,7 @@
}); });
data.forEach(d => { data.forEach(d => {
let url = '/api/stories/v1/fetch/' + d.pid; let url = '/api/stories/v0/fetch/' + d.pid;
axios.get(url) axios.get(url)
.then(res => { .then(res => {
res.data.forEach(item => { res.data.forEach(item => {

View file

@ -36,7 +36,7 @@
methods: { methods: {
fetchStories() { fetchStories() {
axios.get('/api/stories/v1/profile/' + this.pid) axios.get('/api/stories/v0/profile/' + this.pid)
.then(res => { .then(res => {
let data = res.data; let data = res.data;
if(data.length == 0) { if(data.length == 0) {

View file

@ -1424,7 +1424,7 @@
}, },
hasStory() { hasStory() {
axios.get('/api/stories/v1/exists/'+this.profile.id) axios.get('/api/stories/v0/exists/'+this.profile.id)
.then(res => { .then(res => {
this.userStory = res.data; this.userStory = res.data;
}) })

View file

@ -67,4 +67,12 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic'); Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic');
Route::get('timelines/tag/{hashtag}', 'Api\ApiV1Controller@timelineHashtag')->middleware($middleware); Route::get('timelines/tag/{hashtag}', 'Api\ApiV1Controller@timelineHashtag')->middleware($middleware);
}); });
Route::group(['prefix' => 'stories'], function () {
Route::get('v1/recent', 'StoryController@apiV1Recent');
Route::post('v1/add', 'StoryController@apiV1Add')->middleware('throttle:maxStoriesPerDay,1440');
Route::get('v1/fetch/{id}', 'StoryController@apiV1Fetch');
Route::get('v1/profile/{id}', 'StoryController@apiV1Profile');
Route::get('v1/exists/{id}', 'StoryController@apiV1Exists');
Route::delete('v1/delete/{id}', 'StoryController@apiV1Delete')->middleware('throttle:maxStoryDeletePerDay,1440');
});
}); });

View file

@ -179,12 +179,12 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::post('moderate', 'Api\AdminApiController@moderate'); Route::post('moderate', 'Api\AdminApiController@moderate');
}); });
Route::group(['prefix' => 'stories'], function () { Route::group(['prefix' => 'stories'], function () {
Route::get('v1/recent', 'StoryController@apiV1Recent'); Route::get('v0/recent', 'StoryController@apiV1Recent');
Route::post('v1/add', 'StoryController@apiV1Add')->middleware('throttle:maxStoriesPerDay,1440'); Route::post('v0/add', 'StoryController@apiV1Add')->middleware('throttle:maxStoriesPerDay,1440');
Route::get('v1/fetch/{id}', 'StoryController@apiV1Fetch'); Route::get('v0/fetch/{id}', 'StoryController@apiV1Fetch');
Route::get('v1/profile/{id}', 'StoryController@apiV1Profile'); Route::get('v0/profile/{id}', 'StoryController@apiV1Profile');
Route::get('v1/exists/{id}', 'StoryController@apiV1Exists'); Route::get('v0/exists/{id}', 'StoryController@apiV1Exists');
Route::delete('v1/delete/{id}', 'StoryController@apiV1Delete')->middleware('throttle:maxStoryDeletePerDay,1440'); Route::delete('v0/delete/{id}', 'StoryController@apiV1Delete')->middleware('throttle:maxStoryDeletePerDay,1440');
}); });
}); });