forked from kaverti/website
Team, Marketplace improvements and fix thread and post bumping
This commit is contained in:
parent
e004b31fa6
commit
c418b301dd
|
@ -111,7 +111,7 @@
|
|||
|
||||
popover-x="left"
|
||||
></v-swatches><br>
|
||||
<br><b-button class="is-info" @click="colorChanges">Save Changes</b-button>
|
||||
<br><b-button class="is-info" @click="colorChanges" :loading="colorLoading">Save Changes</b-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-6 box">
|
||||
|
@ -131,13 +131,9 @@
|
|||
<div class="column is-4" v-for='user in users' :key='"user-row" + user.Item.id' v-show="user.Item.ItemCategoryId === tab"><div class="card">
|
||||
<div class="card-content">
|
||||
<div class="media-left">
|
||||
<figure class="image is-128x128">
|
||||
<img v-if="user.picture !== 'default' && user.approved" width="128px" height="128px" :src="user.Item.picture">
|
||||
<img v-if="user.picture === 'default' && $store.state.theme === 'light' && user.Item.approved" width="128px" height="128px" src="http://localhost/teams/unknown-light.png">
|
||||
<img v-if="user.picture === 'default' && $store.state.theme === 'dark' && user.Item.approved" width="128px" height="128px" src="http://localhost/teams/unknown-dark.png">
|
||||
<img v-if="$store.state.theme === 'light' && !user.Item.approved" width="128px" height="128px" src="http://localhost/teams/pending-light.png">
|
||||
<img v-if="$store.state.theme === 'dark' && !user.Item.approved" width="128px" height="128px" src="http://localhost/teams/pending-dark.png">
|
||||
</figure>
|
||||
<img v-if=" user.Item.approved" width="128px" height="128px" :src="'http://localhost/marketplace/avatars/' + user.Item.previewFile + '.png'">
|
||||
<img v-if="$store.state.theme === 'light' && !user.Item.approved" width="128px" height="128px" src="http://localhost/marketplace/pending-light.png">
|
||||
<img v-if="$store.state.theme === 'dark' && !user.Item.approved" width="128px" height="128px" src="http://localhost/marketplace/pending-dark.png">
|
||||
</div>
|
||||
<br>
|
||||
<div class="media">
|
||||
|
@ -193,6 +189,7 @@ export default {
|
|||
loading: true,
|
||||
offset: 0,
|
||||
limit: 15,
|
||||
colorLoading: false,
|
||||
refreshAvatar: {
|
||||
loading: false,
|
||||
error: ''
|
||||
|
@ -212,6 +209,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
colorChanges () {
|
||||
this.colorLoading = true
|
||||
this.axios
|
||||
.put(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'avatar/colors', {
|
||||
headColor: this.user.headColor,
|
||||
|
@ -222,6 +220,7 @@ export default {
|
|||
rightLegColor: this.user.rightLegColor
|
||||
})
|
||||
.then(() => {
|
||||
this.colorLoading = false
|
||||
this.axios
|
||||
.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'users/render/refresh', {
|
||||
})
|
||||
|
|
|
@ -17,6 +17,13 @@
|
|||
<div class="section">
|
||||
<div class="">
|
||||
<h1>Friends:</h1>
|
||||
<tab-view
|
||||
:tabs='["Your requests", "Friends", "Requests"]'
|
||||
v-model="friendTab"
|
||||
padding='true'
|
||||
slot='main'
|
||||
>
|
||||
</tab-view>
|
||||
<scroll-load
|
||||
key='user-row'
|
||||
class='columns is-multiline'
|
||||
|
@ -24,7 +31,7 @@
|
|||
:loading='loading'
|
||||
@loadNext='fetchData'
|
||||
>
|
||||
<div class="column is-4" v-for='user in users' :key='"user-row" + user.friend2.id' v-show="user"><div class="card">
|
||||
<div class="column is-4" v-for='user in users' :key='"user-row" + user.friend2.id' v-show="user && user.type === getTab() && user.type !== 'notFriends'"><div class="card">
|
||||
<div class="card-content">
|
||||
<div class="media">
|
||||
<div class="media-content">
|
||||
|
@ -38,6 +45,21 @@
|
|||
<div class="content limit" v-if="user.friend2.description">
|
||||
{{user.friend2.description | truncate(70)}}
|
||||
</div>
|
||||
<b-button @click="removeFriend(user)" v-if="getTab() === 'accepted'" class='is-danger button' icon-left="minus">
|
||||
Remove Friend
|
||||
</b-button>
|
||||
|
||||
<b-button @click="removeFriend(user)" v-if="getTab() === 'pendingCanAccept'" class='is-danger button' icon-left="minus">
|
||||
Deny Request
|
||||
</b-button>
|
||||
|
||||
<b-button @click="removeFriend(user)" v-if="getTab() === 'pending'" class='is-danger button' icon-left="minus">
|
||||
Cancel Request
|
||||
</b-button>
|
||||
|
||||
<b-button @click="doRelationshipAccept(user)" v-if="getTab() === 'pendingCanAccept'" class='is-success button' icon-left="plus">
|
||||
Accept Request
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -54,14 +76,15 @@
|
|||
<script>
|
||||
import LoadingMessage from '../LoadingMessage';
|
||||
import ScrollLoad from '../ScrollLoad';
|
||||
import throttle from 'lodash.throttle';
|
||||
import TabView from "@/components/TabView";
|
||||
import AjaxErrorHandler from '../../assets/js/errorHandler';
|
||||
|
||||
export default {
|
||||
name: 'Inventory',
|
||||
name: 'Friends',
|
||||
components: {
|
||||
LoadingMessage,
|
||||
ScrollLoad
|
||||
ScrollLoad,
|
||||
TabView
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -71,6 +94,7 @@ export default {
|
|||
loading: true,
|
||||
offset: 0,
|
||||
limit: 15,
|
||||
friendTab: 1,
|
||||
|
||||
roleOptions: [
|
||||
{ name: 'Admins', value: 'admin' },
|
||||
|
@ -85,15 +109,159 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
removeFriend (user) {
|
||||
this.axios
|
||||
.put(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/remove', {
|
||||
friend: user.friend2.username
|
||||
})
|
||||
.then(() => {
|
||||
this.resetFetchData()
|
||||
this.description.loading = false
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data, this.resetFetchData())
|
||||
.catch(e => {
|
||||
this.resetFetchData()
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
this.resetFetchData()
|
||||
this.description.loading = false
|
||||
|
||||
AjaxErrorHandler(this.$store)(e, error => {
|
||||
this.description.error = error.message
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data, this.resetFetchData())
|
||||
.catch(e => {
|
||||
this.resetFetchData()
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
doRelationship (user) {
|
||||
this.axios
|
||||
.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/send', {
|
||||
friend: user.friend2.username
|
||||
})
|
||||
.then(() => {
|
||||
this.resetFetchData()
|
||||
this.description.loading = false
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
this.resetFetchData()
|
||||
this.description.loading = false
|
||||
|
||||
AjaxErrorHandler(this.$store)(e, error => {
|
||||
this.description.error = error.message
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
doRelationshipAccept (user) {
|
||||
this.axios
|
||||
.put(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/accept', {
|
||||
friend: user.friend2.username
|
||||
})
|
||||
.then(() => {
|
||||
this.resetFetchData()
|
||||
this.description.loading = false
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
this.resetFetchData()
|
||||
this.description.loading = false
|
||||
|
||||
AjaxErrorHandler(this.$store)(e, error => {
|
||||
this.description.error = error.message
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
getTab () {
|
||||
if(this.friendTab === 0) {
|
||||
return 'pending'
|
||||
} else if(this.friendTab === 1) {
|
||||
return 'accepted'
|
||||
} else if(this.friendTab === 2) {
|
||||
return 'pendingCanAccept'
|
||||
}
|
||||
},
|
||||
fetchData () {
|
||||
if(this.offset === null) return;
|
||||
|
||||
let url = process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/get/' + this.$route.params.username + `?
|
||||
sort=${this.tableSort.column}
|
||||
&order=${this.tableSort.sort}
|
||||
&offset=${this.offset}
|
||||
&inventory=true
|
||||
`;
|
||||
let url = process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/getAll'
|
||||
if(this.roleSelected.length === 1) {
|
||||
url += '&role=' + this.roleSelected[0];
|
||||
}
|
||||
|
@ -122,7 +290,6 @@ export default {
|
|||
});
|
||||
},
|
||||
resetFetchData () {
|
||||
this.offset = 0;
|
||||
this.users = [];
|
||||
|
||||
this.fetchData();
|
||||
|
@ -146,13 +313,6 @@ export default {
|
|||
},
|
||||
mounted () {
|
||||
this.fetchData();
|
||||
},
|
||||
watch: {
|
||||
tableSort: 'resetFetchData',
|
||||
roleSelected: 'resetFetchData',
|
||||
search: throttle(function () {
|
||||
this.resetFetchData();
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -149,43 +149,34 @@
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
filteredThreads () {
|
||||
var categories = {};
|
||||
filteredThreads () {
|
||||
var categories = {};
|
||||
var filter = this.selectedFilterOption
|
||||
|
||||
this.$store.state.meta.categories.forEach(category => {
|
||||
categories[category.value] = category.name;
|
||||
});
|
||||
|
||||
return this.threads.filter(thread => {
|
||||
return (thread.Category.value === this.selectedCategory) || (this.selectedCategory === 'ALL');
|
||||
}).map(thread => {
|
||||
var _thread = Object.assign({}, thread);
|
||||
_thread.category = categories[thread.Category.value];
|
||||
|
||||
return _thread;
|
||||
}).sort((a, b) => {
|
||||
categories[category.value] = category.name;
|
||||
});
|
||||
return this.threads.filter(thread => {
|
||||
return (thread.Category.value === this.selectedCategory) || (this.selectedCategory === 'ALL');
|
||||
}).map(thread => {
|
||||
var _thread = Object.assign({}, thread);
|
||||
_thread.category = categories[thread.Category.value];
|
||||
return _thread;
|
||||
}).sort((a, b) => {
|
||||
if(filter === 'NEW') {
|
||||
if(this.threads.Posts) {
|
||||
let aDate = new Date(a.Posts.createdAt)
|
||||
let bDate = new Date(b.Posts.createdAt)
|
||||
return bDate - aDate;
|
||||
} else {
|
||||
let aDate = new Date(a.Posts.createdAt)
|
||||
let bDate = new Date(b.Posts.createdAt)
|
||||
return bDate - aDate;
|
||||
}
|
||||
} else if(filter === 'MOST_ACTIVE') {
|
||||
return b.postsCount - a.postsCount;
|
||||
}
|
||||
}).filter(thread => {
|
||||
if(filter === 'NO_REPLIES' && thread.postsCount-1) {
|
||||
return false
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
let aDate = new Date(a.Posts[0].createdAt)
|
||||
let bDate = new Date(b.Posts[0].createdAt)
|
||||
return bDate - aDate;
|
||||
} else if(filter === 'MOST_ACTIVE') {
|
||||
return b.postsCount - a.postsCount;
|
||||
}
|
||||
}).filter(thread => {
|
||||
if(filter === 'NO_REPLIES' && thread.postsCount-1) {
|
||||
return false
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
categories () {
|
||||
return this.$store.getters.alphabetizedCategories
|
||||
},
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<b-tooltip style="float: right;" v-bind:label="user.name + ' has join requests disabled, you can only be added by the owner, or someone with add privileges' ">
|
||||
<b-button v-if="$store.state.username && !$store.state.UserId === user.OwnerId" @click="joinTeam()" style="float: right;">Join team</b-button>
|
||||
</b-tooltip>
|
||||
<b-button v-if="$store.state.username && $store.state.UserId === user.OwnerId" class="button is-primary" style="float: right" @click='$router.push(`/team/${user.username}`)'>
|
||||
<b-button v-if="$store.state.username && joined && roles.administrator" class="button is-primary" style="float: right" @click='$router.push(`/team/${user.username}`)'>
|
||||
Edit Team
|
||||
</b-button>
|
||||
<b-button v-if="$store.state.username && $store.state.UserId !== user.OwnerId && !joined" class="button is-primary" style="float: right" @click='joinTeam()'>
|
||||
|
@ -104,7 +104,7 @@
|
|||
Leave Team
|
||||
</b-button>
|
||||
<br><br>
|
||||
<b-button v-if="joined" style="float: right" @click="generateInvite()">
|
||||
<b-button v-if="joined && roles.inviteUsers" style="float: right" @click="generateInvite()">
|
||||
Invite
|
||||
</b-button>
|
||||
</div>
|
||||
|
@ -165,7 +165,8 @@ export default {
|
|||
},
|
||||
relationships: {
|
||||
type: ''
|
||||
}
|
||||
},
|
||||
roles: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -197,6 +198,9 @@ export default {
|
|||
this.fetchData();
|
||||
},
|
||||
fetchData () {
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `teams/view/${this.$route.params.username}/roles/permissions/${this.$store.state.username}`)
|
||||
.then(res => this.roles = res.data)
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `teams/view/${this.$route.params.username}`)
|
||||
.then(res => this.user = res.data)
|
||||
|
@ -205,7 +209,7 @@ export default {
|
|||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
if (invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
>
|
||||
<div class="column is-4" v-for='user in userRoles' :key='"user-row" + user.User.username' v-show="user"><div class="card">
|
||||
<div class="card-content">
|
||||
<router-link :to="'/u/' + user.username"><b-button style="float:right;">View</b-button></router-link>
|
||||
<router-link :to="'/u/' + user.User.username"><b-button style="float:right;">View</b-button></router-link>
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<figure class="image is-64x64">
|
||||
|
|
|
@ -1,5 +1,256 @@
|
|||
<style>
|
||||
.team-img {
|
||||
border-radius: 50%;
|
||||
}
|
||||
.vertical-alt {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-ms-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.limit{
|
||||
margin-top: 0.5rem;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<main>
|
||||
<div class="section">
|
||||
<div class="">
|
||||
<h1>Members:</h1>
|
||||
<scroll-load
|
||||
key='user-row'
|
||||
class='columns is-multiline'
|
||||
v-if='userRoles.length'
|
||||
:loading='loading'
|
||||
@loadNext='fetchData'
|
||||
>
|
||||
<div class="column is-4" v-for='user in userRoles' :key='"user-row" + user.User.username' v-show="user"><div class="card">
|
||||
<div class="card-content">
|
||||
<router-link :to="'/u/' + user.User.username"><b-button style="float:right;">View</b-button></router-link>
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<figure class="image is-64x64">
|
||||
<avatar-icon :user="user.User" size="small"></avatar-icon>
|
||||
</figure>
|
||||
</div>
|
||||
<div class="media-content">
|
||||
<p class="title is-4">{{user.User.username}} <b-tag class="is-info" v-if="team.OwnerId === user.User.id">OWNER</b-tag> </p>
|
||||
<b-tag v-if="user.Role">{{user.Role.name}}</b-tag> <b-tag v-if="user.Role2">{{user.Role2.name}}</b-tag> <b-tag v-if="user.Role3">{{user.Role3.name}}</b-tag> <b-tag v-if="user.Role4">{{user.Role4.name}}</b-tag> <b-tag v-if="user.Role5">{{user.Role5.name}}</b-tag> <b-tag v-if="user.Role6">{{user.Role6.name}}</b-tag> <b-tag v-if="user.Role7">{{user.Role7.name}}</b-tag> <b-tag v-if="user.Role8">{{user.Role8.name}}</b-tag> <b-tag v-if="user.Role9">{{user.Role9.name}}</b-tag> <b-tag v-if="user.Role10">{{user.Role10.name}}</b-tag> </div>
|
||||
</div>
|
||||
|
||||
<div class="content limit">
|
||||
{{user.User.description}}
|
||||
</div>
|
||||
<b-button @click="updateRoles(user)">Assign and remove roles</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</scroll-load>
|
||||
</div>
|
||||
</div>
|
||||
<p name='fade' mode='out-in'>
|
||||
<center><loading-message key='loading' v-if='loading'></loading-message></center>
|
||||
<center><div class='overlay_message' v-if='!loading && !users.length'>
|
||||
Something went wrong while loading the users, check your internet connection, or check the <a href="https://status.troplo.com">Service Status</a>
|
||||
</div></center></p>
|
||||
</main>
|
||||
</template>
|
||||
<script>
|
||||
import LoadingMessage from '../LoadingMessage';
|
||||
import ScrollLoad from '../ScrollLoad';
|
||||
import throttle from 'lodash.throttle';
|
||||
import AjaxErrorHandler from '../../assets/js/errorHandler';
|
||||
import AvatarIcon from '../AvatarIcon';
|
||||
|
||||
export default {
|
||||
name: 'TeamMembers',
|
||||
components: {
|
||||
LoadingMessage,
|
||||
ScrollLoad,
|
||||
AvatarIcon
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
search: '',
|
||||
users: [],
|
||||
userRoles: [],
|
||||
roles: [],
|
||||
team: [],
|
||||
rolePrepend: {
|
||||
username: '',
|
||||
Role1Id: '',
|
||||
Role2Id: '',
|
||||
Role3Id: '',
|
||||
Role4Id: '',
|
||||
Role5Id: '',
|
||||
Role6Id: '',
|
||||
Role7Id: '',
|
||||
Role8Id: '',
|
||||
Role9Id: '',
|
||||
Role10Id: ''
|
||||
},
|
||||
|
||||
loading: true,
|
||||
offset: 0,
|
||||
limit: 15,
|
||||
showTeamTab: 0,
|
||||
createTeamModal: false,
|
||||
tcreateProd: {
|
||||
username: '',
|
||||
name: '',
|
||||
|
||||
loading: false,
|
||||
|
||||
errors: {
|
||||
username: '',
|
||||
name: ''
|
||||
}
|
||||
},
|
||||
|
||||
roleOptions: [
|
||||
{ name: 'Admins', value: 'admin' },
|
||||
{ name: 'Users', value: 'user' }
|
||||
],
|
||||
roleSelected: ['admin', 'user'],
|
||||
|
||||
tableSort: {
|
||||
column: 'username',
|
||||
sort: 'desc'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clearTeamErrors() {
|
||||
this.tcreateProd.errors.username = ''
|
||||
this.tcreateProd.errors.name = ''
|
||||
},
|
||||
closeAccountModal() {
|
||||
this.createTeamModal = false
|
||||
},
|
||||
updateRoles(user) {
|
||||
this.rolePrepend.username = user.User.username
|
||||
},
|
||||
fetchData () {
|
||||
if(this.offset === null) return;
|
||||
|
||||
let url = process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'teams/view/' + this.$route.params.username + "/members" + `?
|
||||
sort=${this.tableSort.column}
|
||||
&order=${this.tableSort.sort}
|
||||
&offset=${this.offset}
|
||||
`;
|
||||
if(this.roleSelected.length === 1) {
|
||||
url += '&role=' + this.roleSelected[0];
|
||||
}
|
||||
if(this.search.length) {
|
||||
url += '&search=' + encodeURIComponent(this.search.trim());
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.axios
|
||||
.get(url)
|
||||
.then(res => {
|
||||
this.users.push(...res.data);
|
||||
this.loading = /*loading =*/ false;
|
||||
|
||||
//If returned data is less than the limit
|
||||
//then there must be no more pages to paginate
|
||||
if(res.data.length < this.limit) {
|
||||
this.offset = null;
|
||||
} else {
|
||||
this.offset+= this.limit;
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
AjaxErrorHandler(this.$store)(e);
|
||||
this.loading = /*loading =*/ false;
|
||||
});
|
||||
this.loading = true;
|
||||
this.axios
|
||||
.get( process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'teams/view/' + this.$route.params.username + "/userRoles")
|
||||
.then(res => {
|
||||
this.userRoles.push(...res.data);
|
||||
this.loading = /*loading =*/ false;
|
||||
|
||||
//If returned data is less than the limit
|
||||
//then there must be no more pages to paginate
|
||||
if(res.data.length < this.limit) {
|
||||
this.offset = null;
|
||||
} else {
|
||||
this.offset+= this.limit;
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
AjaxErrorHandler(this.$store)(e);
|
||||
this.loading = /*loading =*/ false;
|
||||
});
|
||||
this.axios
|
||||
.get( process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'teams/view/' + this.$route.params.username + "/roles")
|
||||
.then(res => {
|
||||
this.roles.push(...res.data);
|
||||
this.loading = /*loading =*/ false;
|
||||
|
||||
//If returned data is less than the limit
|
||||
//then there must be no more pages to paginate
|
||||
if(res.data.length < this.limit) {
|
||||
this.offset = null;
|
||||
} else {
|
||||
this.offset+= this.limit;
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
AjaxErrorHandler(this.$store)(e);
|
||||
this.loading = /*loading =*/ false;
|
||||
});
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `teams/view/${this.$route.params.username}`)
|
||||
.then(res => this.team = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
return error.name === 'accountDoesNotExist'
|
||||
})
|
||||
|
||||
if(invalidId) {
|
||||
this.$store.commit('set404Page', true)
|
||||
} else {
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
resetFetchData () {
|
||||
this.offset = 0;
|
||||
this.users = [];
|
||||
|
||||
this.fetchData();
|
||||
}
|
||||
},
|
||||
getNewerUsers () {
|
||||
this.loadingNewer = true
|
||||
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'teams/view/' + this.$route.params.username + "/members" + '?limit=' + this.newUsers)
|
||||
.then(res => {
|
||||
this.loadingNewer = false
|
||||
this.newUsers = 0
|
||||
|
||||
this.threads.unshift(...res.data.Threads)
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loadingNewer = false
|
||||
AjaxErrorHandler(this.$store)(e)
|
||||
})
|
||||
},
|
||||
mounted () {
|
||||
this.fetchData();
|
||||
},
|
||||
watch: {
|
||||
tableSort: 'resetFetchData',
|
||||
roleSelected: 'resetFetchData',
|
||||
search: throttle(function () {
|
||||
this.resetFetchData();
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -215,18 +215,13 @@
|
|||
|
||||
this.axios.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'forums/thread', {
|
||||
name: this.name,
|
||||
category: this.selectedCategory
|
||||
category: this.selectedCategory,
|
||||
content: this.editor,
|
||||
mentions: this.mentions
|
||||
}).then(res => {
|
||||
thread = res.data
|
||||
|
||||
let ajax = []
|
||||
ajax.push(
|
||||
this.axios.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'forums/post', {
|
||||
threadId: res.data.id,
|
||||
content: this.editor,
|
||||
mentions: this.mentions
|
||||
})
|
||||
)
|
||||
|
||||
if(this.showPoll) {
|
||||
ajax.push(
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
Accept Friend Request
|
||||
</b-button>
|
||||
<b-button @click="removeFriend" v-if="$store.state.experimentsStore.relationships && relationship.type === 'pendingCanAccept' && user.username !== $store.state.username && $store.state.username" class='is-danger button' icon-left="minus">
|
||||
Remove Friend Request
|
||||
Deny Friend Request
|
||||
</b-button>
|
||||
<b-button @click="doRelationship" v-if="$store.state.experimentsStore.relationships && user && relationship.type === 'notFriends' && user.username !== $store.state.username && $store.state.username" class='is-info button' icon-left="plus">
|
||||
Send friend request
|
||||
|
@ -198,7 +198,7 @@
|
|||
},
|
||||
refreshFriend() {
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
},
|
||||
removeFriend () {
|
||||
|
@ -210,7 +210,7 @@
|
|||
this.refreshFriend()
|
||||
this.description.loading = false
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data, this.refreshFriend())
|
||||
.catch(e => {
|
||||
this.refreshFriend()
|
||||
|
@ -233,7 +233,7 @@
|
|||
this.description.error = error.message
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data, this.refreshFriend())
|
||||
.catch(e => {
|
||||
this.refreshFriend()
|
||||
|
@ -258,7 +258,7 @@
|
|||
this.refreshFriend()
|
||||
this.description.loading = false
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
|
@ -280,7 +280,7 @@
|
|||
this.description.error = error.message
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
|
@ -304,7 +304,7 @@
|
|||
this.refreshFriend()
|
||||
this.description.loading = false
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
|
@ -326,7 +326,7 @@
|
|||
this.description.error = error.message
|
||||
})
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
|
@ -363,7 +363,7 @@
|
|||
.then(res => this.user = res.data)
|
||||
|
||||
this.axios
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/${this.$route.params.username}`)
|
||||
.get(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `relationships/get/${this.$route.params.username}`)
|
||||
.then(res => this.relationship = res.data)
|
||||
.catch(e => {
|
||||
let invalidId = e.response.data.errors.find(error => {
|
||||
|
|
|
@ -88,7 +88,7 @@ export default {
|
|||
fetchData () {
|
||||
if(this.offset === null) return;
|
||||
|
||||
let url = process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/get/' + this.$route.params.username + `?
|
||||
let url = process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'relationships/user/' + this.$route.params.username + `?
|
||||
sort=${this.tableSort.column}
|
||||
&order=${this.tableSort.sort}
|
||||
&offset=${this.offset}
|
||||
|
|
|
@ -59,10 +59,17 @@ let Errors = {
|
|||
'This team does not exist.',
|
||||
400
|
||||
],
|
||||
inviteDenied: [
|
||||
'You need to have a role that has the Invite Member permission to perform this action',
|
||||
400
|
||||
],
|
||||
itemUnavailable: [
|
||||
'This item is currently unavailable at this time.',
|
||||
400
|
||||
],
|
||||
renderServiceUnavailable: [
|
||||
'The rendering service is currently unavailable, please contact a staff member.'
|
||||
],
|
||||
joinedTeam: [
|
||||
'You are already in this Team',
|
||||
400
|
||||
|
|
|
@ -27,9 +27,9 @@ bpy.data.objects['Left Leg'].active_material.diffuse_color = hex_to_rgb('#3D556E
|
|||
bpy.data.objects['Right Leg'].select = True
|
||||
bpy.data.objects['Right Leg'].active_material.diffuse_color = hex_to_rgb('#C0382B')
|
||||
|
||||
face_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/6ca14f5e8e132cd0c2337bb3f3f2699b.png')
|
||||
face_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/defaultFace.png')
|
||||
bpy.data.textures['Face'].image = face_Image
|
||||
shirt_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/0.png')
|
||||
shirt_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/91b08cbaa4f12e959991779385b81125.png')
|
||||
bpy.data.textures['Shirt'].image = shirt_Image
|
||||
bpy.data.textures['ShirtR'].image = shirt_Image
|
||||
bpy.data.textures['ShirtL'].image = shirt_Image
|
||||
|
@ -42,5 +42,5 @@ for obj in bpy.data.objects:
|
|||
bpy.ops.view3d.camera_to_view_selected()
|
||||
scene = bpy.context.scene
|
||||
scene.render.image_settings.file_format = 'PNG'
|
||||
scene.render.filepath = 'C:/xampp21/htdocs/user/avatars/full/9e72f3a5ce69ce1487320f035e2fb334.png'
|
||||
scene.render.filepath = 'C:/xampp21/htdocs/user/avatars/full/e3e5ea925f74dc27e63243285ecb4590.png'
|
||||
bpy.ops.render.render(write_still = 1)
|
|
@ -0,0 +1,46 @@
|
|||
import bpy
|
||||
def hex_to_rgb(value):
|
||||
gamma = 2.05
|
||||
value = value.lstrip('#')
|
||||
lv = len(value)
|
||||
fin = list(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
|
||||
r = pow(fin[0] / 255, gamma)
|
||||
g = pow(fin[1] / 255, gamma)
|
||||
b = pow(fin[2] / 255, gamma)
|
||||
fin.clear()
|
||||
fin.append(r)
|
||||
fin.append(g)
|
||||
fin.append(b)
|
||||
return tuple(fin)
|
||||
bpy.ops.wm.open_mainfile(filepath='C:/Users/matth/Documents/GitHub/website/rendering/avatar.blend')
|
||||
bpy.data.objects['Head'].select = True
|
||||
bpy.data.materials['Head'].diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.materials['Face'].diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Left Arm'].select = True
|
||||
bpy.data.objects['Left Arm'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Torso'].select = True
|
||||
bpy.data.objects['Torso'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Right Arm'].select = True
|
||||
bpy.data.objects['Right Arm'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Left Leg'].select = True
|
||||
bpy.data.objects['Left Leg'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Right Leg'].select = True
|
||||
bpy.data.objects['Right Leg'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
|
||||
face_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/defaultFace.png')
|
||||
bpy.data.textures['Face'].image = face_Image
|
||||
shirt_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/c969689cc4830dc289d8c1085ef248c0.png')
|
||||
bpy.data.textures['Shirt'].image = shirt_Image
|
||||
bpy.data.textures['ShirtR'].image = shirt_Image
|
||||
bpy.data.textures['ShirtL'].image = shirt_Image
|
||||
pants_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/0.png')
|
||||
bpy.data.textures['PantsR'].image = pants_Image
|
||||
bpy.data.textures['PantsL'].image = pants_Image
|
||||
for obj in bpy.data.objects:
|
||||
obj.select = False
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
bpy.ops.view3d.camera_to_view_selected()
|
||||
scene = bpy.context.scene
|
||||
scene.render.image_settings.file_format = 'PNG'
|
||||
scene.render.filepath = 'C:/xampp21/htdocs/marketplace/avatars/d180a5f2ce14af49181b648a69830bde.png'
|
||||
bpy.ops.render.render(write_still = 1)
|
|
@ -0,0 +1,46 @@
|
|||
import bpy
|
||||
def hex_to_rgb(value):
|
||||
gamma = 2.05
|
||||
value = value.lstrip('#')
|
||||
lv = len(value)
|
||||
fin = list(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
|
||||
r = pow(fin[0] / 255, gamma)
|
||||
g = pow(fin[1] / 255, gamma)
|
||||
b = pow(fin[2] / 255, gamma)
|
||||
fin.clear()
|
||||
fin.append(r)
|
||||
fin.append(g)
|
||||
fin.append(b)
|
||||
return tuple(fin)
|
||||
bpy.ops.wm.open_mainfile(filepath='C:/Users/matth/Documents/GitHub/website/rendering/avatar.blend')
|
||||
bpy.data.objects['Head'].select = True
|
||||
bpy.data.materials['Head'].diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.materials['Face'].diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Left Arm'].select = True
|
||||
bpy.data.objects['Left Arm'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Torso'].select = True
|
||||
bpy.data.objects['Torso'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Right Arm'].select = True
|
||||
bpy.data.objects['Right Arm'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Left Leg'].select = True
|
||||
bpy.data.objects['Left Leg'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
bpy.data.objects['Right Leg'].select = True
|
||||
bpy.data.objects['Right Leg'].active_material.diffuse_color = hex_to_rgb('#ffffff')
|
||||
|
||||
face_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/3cde429b13ed37948ded93af2fbecb11.png')
|
||||
bpy.data.textures['Face'].image = face_Image
|
||||
shirt_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/0.png')
|
||||
bpy.data.textures['Shirt'].image = shirt_Image
|
||||
bpy.data.textures['ShirtR'].image = shirt_Image
|
||||
bpy.data.textures['ShirtL'].image = shirt_Image
|
||||
pants_Image = bpy.data.images.load(filepath = 'C:/Users/matth/Documents/GitHub/website/rendering/global/0.png')
|
||||
bpy.data.textures['PantsR'].image = pants_Image
|
||||
bpy.data.textures['PantsL'].image = pants_Image
|
||||
for obj in bpy.data.objects:
|
||||
obj.select = False
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
bpy.ops.view3d.camera_to_view_selected()
|
||||
scene = bpy.context.scene
|
||||
scene.render.image_settings.file_format = 'PNG'
|
||||
scene.render.filepath = 'C:/xampp21/htdocs/marketplace/avatars/c5ed7eeb9c335db47bc6f5c099bb488f.png'
|
||||
bpy.ops.render.render(write_still = 1)
|
|
@ -9,7 +9,7 @@ const cryptoRandomString = require("crypto-random-string")
|
|||
const limiter = rateLimit({
|
||||
windowMs: 60 * 1000,
|
||||
max: 3,
|
||||
message: "You are being rate limited"
|
||||
message: "{\"errors\":[{\"name\":\"rateLimit\",\"message\":\"You may only make 3 requests to this endpoint per minute, if you performed an action such as avatar color changing, those changes were saved, however your avatar was not re-rendered, please re-render your avatar.\",\"status\":429}]}"
|
||||
});
|
||||
let { User, Sequelize, Item } = require('../models')
|
||||
const Errors = require('../lib/errors')
|
||||
|
@ -50,7 +50,6 @@ router.post("/refresh", limiter, auth, async(req, res, next) => {
|
|||
}
|
||||
})
|
||||
}
|
||||
console.log(user)
|
||||
let rootPathRender = "C:/Users/matth/Documents/GitHub/website/";
|
||||
let img2 = cryptoRandomString({length: 32})
|
||||
let img = img2
|
||||
|
|
|
@ -316,7 +316,7 @@ router.post('/upload/:id', auth, limiter, upload.single('image'), async (req, re
|
|||
fs.writeFile("rendering/usercontent/"+marketplace.id+".py", python, function(err,data){
|
||||
if(err) { console.log(err) }
|
||||
})
|
||||
|
||||
await Inventory.create({UserId: req.userData.UserId, purchasePrice: 0, isReselling: false, isResellingPrice: 0, ItemId: marketplace.id, boughtFrom: marketplace.UserId, resellType: 0, auctionId: 0})
|
||||
exec("blender -b -P rendering/usercontent/"+marketplace.id+".py", (err, stdout, stderr) => {
|
||||
if(err) { console.log(err) }
|
||||
console.log("stdout: " + stdout);
|
||||
|
@ -340,7 +340,9 @@ router.put('/apply/:id', auth, async (req, res, next) => {
|
|||
where: {id: item.ItemId}
|
||||
})
|
||||
if (marketplaceItem) {
|
||||
console.log(marketplaceItem)
|
||||
if(!marketplaceItem.approved) {
|
||||
throw Errors.itemUnavailable
|
||||
}
|
||||
if (marketplaceItem.ItemCategoryId === 0) {
|
||||
await User.update({ hatId: marketplaceItem.id }, {where: {id: req.userData.UserId}})
|
||||
res.json({success: true})
|
||||
|
|
|
@ -121,7 +121,7 @@ router.put('/remove', auth, async(req, res, next) => {
|
|||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
router.get('/:username', auth, async(req, res, next) => {
|
||||
router.get('/get/:username', auth, async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
where: {username: req.userData.username}
|
||||
|
@ -152,7 +152,7 @@ router.get('/:username', auth, async(req, res, next) => {
|
|||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
router.get('/get/:username', auth, async(req, res, next) => {
|
||||
router.get('/user/:username', auth, async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
where: {username: req.params.username}
|
||||
|
@ -179,7 +179,7 @@ router.get('/get/:username', auth, async(req, res, next) => {
|
|||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
router.get('/:username', auth, async(req, res, next) => {
|
||||
router.get('/getAll', auth, async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
where: {username: req.userData.username}
|
||||
|
@ -189,24 +189,18 @@ router.get('/:username', auth, async(req, res, next) => {
|
|||
res.status(200)
|
||||
res.json({success: false})
|
||||
}
|
||||
let queryObj2 = {
|
||||
where: {username: req.params.username}
|
||||
}
|
||||
let user2 = await User.findOne(queryObj2)
|
||||
if(!user2) {
|
||||
throw Errors.accountDoesNotExist
|
||||
}
|
||||
let checkIfSent = await Relationship.findOne({
|
||||
where: {friend1Id: user.id, friend2Id: user2.id},
|
||||
let checkIfSent = await Relationship.findAll({
|
||||
where: {friend1Id: user.id},
|
||||
include: [{ model: User, as: 'friend1', attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] }, { model: User, as: 'friend2', attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] } ]
|
||||
})
|
||||
if (checkIfSent) {
|
||||
res.status(200)
|
||||
res.json(checkIfSent.toJSON())
|
||||
res.json(checkIfSent)
|
||||
} else {
|
||||
res.status(200)
|
||||
res.json({type: 'notFriends'})
|
||||
res.json({})
|
||||
}
|
||||
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
module.exports = router
|
||||
|
|
221
routes/team.js
221
routes/team.js
|
@ -355,6 +355,227 @@ router.get('/view/:username/roles/name/:id', async(req, res, next) => {
|
|||
} catch (e) { next(e) }
|
||||
})
|
||||
|
||||
router.get('/view/:username/roles/permissions/:id', async(req, res, next) => {
|
||||
try {
|
||||
let team = await Team.findOne({
|
||||
where: {username: req.params.username}
|
||||
});
|
||||
let user = await User.findOne({
|
||||
where: {username: req.params.id}
|
||||
});
|
||||
if(user && team) {
|
||||
let isAuthMem = await TeamMembers.findOne({
|
||||
where: {UserId: user.id, TeamId: team.id}
|
||||
});
|
||||
if (!isAuthMem) {
|
||||
throw Errors.notInTeam
|
||||
}
|
||||
let isAuthRole = await TeamMemberRole.findOne({
|
||||
where: {UserId: user.id, TeamId: team.id}
|
||||
})
|
||||
let isAuthOwner = await Team.findOne({
|
||||
where: {OwnerId: user.id, id: team.id}
|
||||
})
|
||||
let isAuth1 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, inviteUsers: true}
|
||||
})
|
||||
let isAuth2 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth3 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth4 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth5 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth6 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth7 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth8 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth9 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, inviteUsers: true}
|
||||
})
|
||||
let isAuth10 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, inviteUsers: true}
|
||||
})
|
||||
const allowArray = [
|
||||
isAuth1,
|
||||
isAuth2,
|
||||
isAuth3,
|
||||
isAuth4,
|
||||
isAuth5,
|
||||
isAuth6,
|
||||
isAuth7,
|
||||
isAuth8,
|
||||
isAuth9,
|
||||
isAuth10,
|
||||
isAuthOwner
|
||||
]
|
||||
let invite = allowArray.some(function (el) {
|
||||
return el !== null;
|
||||
});
|
||||
let isAuth11 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, administrator: true}
|
||||
})
|
||||
let isAuth12 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, administrator: true}
|
||||
})
|
||||
let isAuth13 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, administrator: true}
|
||||
})
|
||||
let isAuth14 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, administrator: true}
|
||||
})
|
||||
let isAuth15 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, administrator: true}
|
||||
})
|
||||
let isAuth16 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, administrator: true}
|
||||
})
|
||||
let isAuth17 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, administrator: true}
|
||||
})
|
||||
let isAuth18 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, administrator: true}
|
||||
})
|
||||
let isAuth19 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, administrator: true}
|
||||
})
|
||||
let isAuth20 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, administrator: true}
|
||||
})
|
||||
const adminArray = [
|
||||
isAuth10,
|
||||
isAuth12,
|
||||
isAuth13,
|
||||
isAuth14,
|
||||
isAuth15,
|
||||
isAuth16,
|
||||
isAuth17,
|
||||
isAuth18,
|
||||
isAuth19,
|
||||
isAuth20,
|
||||
isAuthOwner
|
||||
]
|
||||
let administrator = adminArray.some(function (el) {
|
||||
return el !== null;
|
||||
});
|
||||
let isAuth21 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth22 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth23 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth24 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth25 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth26 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth27 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth28 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth29 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, changeTeamMeta: true}
|
||||
})
|
||||
let isAuth30 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, changeTeamMeta: true}
|
||||
})
|
||||
const metaArray = [
|
||||
isAuth21,
|
||||
isAuth22,
|
||||
isAuth23,
|
||||
isAuth24,
|
||||
isAuth25,
|
||||
isAuth26,
|
||||
isAuth27,
|
||||
isAuth28,
|
||||
isAuth29,
|
||||
isAuth30,
|
||||
isAuthOwner
|
||||
]
|
||||
let meta = metaArray.some(function (el) {
|
||||
return el !== null;
|
||||
});
|
||||
let isAuth31 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth32 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth33 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth34 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth35 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth36 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth37 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth38 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth39 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth40 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, changeTeamRoles: true}
|
||||
})
|
||||
const roleArray = [
|
||||
isAuth31,
|
||||
isAuth32,
|
||||
isAuth33,
|
||||
isAuth34,
|
||||
isAuth35,
|
||||
isAuth36,
|
||||
isAuth37,
|
||||
isAuth38,
|
||||
isAuth39,
|
||||
isAuth40,
|
||||
isAuthOwner
|
||||
]
|
||||
let role = roleArray.some(function (el) {
|
||||
return el !== null;
|
||||
});
|
||||
if (team) {
|
||||
if (team.banned) {
|
||||
res.status(200)
|
||||
res.json({administrator: false, inviteUsers: false})
|
||||
}
|
||||
res.json({inviteUsers: invite, administrator: administrator, changeTeamMeta: meta, changeTeamRoles: role})
|
||||
} else {
|
||||
throw Errors.accountDoesNotExist
|
||||
}
|
||||
} else {
|
||||
throw Errors.accountDoesNotExist
|
||||
}
|
||||
|
||||
} catch (e) { next(e) }
|
||||
})
|
||||
|
||||
router.get('/', async(req, res, next) => {
|
||||
try {
|
||||
let sortFields = {
|
||||
|
|
|
@ -517,6 +517,162 @@ router.put('/roles/modify/:username/:id', auth, async(req, res, next) => {
|
|||
} catch (e) { next(e) }
|
||||
})
|
||||
|
||||
router.put('/members/modify/:username/:id', auth, async(req, res, next) => {
|
||||
try {
|
||||
let team = await Team.findOne({
|
||||
where: {username: req.params.username}
|
||||
});
|
||||
let userFind = await User.findOne({
|
||||
where: {username: req.params.id}
|
||||
})
|
||||
let user = await TeamMemberRole.findOne({
|
||||
where: {UserId: userFind.id}
|
||||
});
|
||||
let isAuthMem = await TeamMembers.findOne({
|
||||
where: {UserId: req.userData.UserId, TeamId: team.id}
|
||||
});
|
||||
if(!isAuthMem) {
|
||||
throw Errors.notInTeam
|
||||
}
|
||||
let isAuthRole = await TeamMemberRole.findOne({
|
||||
where: {UserId: req.userData.UserId, TeamId: team.id}
|
||||
})
|
||||
let isAuth1 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, administrator: true}
|
||||
})
|
||||
let isAuth2 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, administrator: true}
|
||||
})
|
||||
let isAuth3 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, administrator: true}
|
||||
})
|
||||
let isAuth4 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, administrator: true}
|
||||
})
|
||||
let isAuth5 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, administrator: true}
|
||||
})
|
||||
let isAuth6 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, administrator: true}
|
||||
})
|
||||
let isAuth7 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, administrator: true}
|
||||
})
|
||||
let isAuth8 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, administrator: true}
|
||||
})
|
||||
let isAuth9 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, administrator: true}
|
||||
})
|
||||
let isAuth10 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, administrator: true}
|
||||
})
|
||||
let isAuth11 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth12 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth13 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth14 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth15 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth16 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth17 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth18 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth19 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, changeTeamRoles: true}
|
||||
})
|
||||
let isAuth20 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, changeTeamRoles: true}
|
||||
})
|
||||
const allowArray = [
|
||||
isAuth1,
|
||||
isAuth2,
|
||||
isAuth3,
|
||||
isAuth4,
|
||||
isAuth5,
|
||||
isAuth6,
|
||||
isAuth7,
|
||||
isAuth8,
|
||||
isAuth9,
|
||||
isAuth10,
|
||||
isAuth11,
|
||||
isAuth12,
|
||||
isAuth13,
|
||||
isAuth14,
|
||||
isAuth15,
|
||||
isAuth16,
|
||||
isAuth17,
|
||||
isAuth18,
|
||||
isAuth19,
|
||||
isAuth20
|
||||
]
|
||||
let otherThanNull = allowArray.some(function (el) {
|
||||
return el !== null;
|
||||
});
|
||||
if(team && otherThanNull) {
|
||||
let queryObj3 = {
|
||||
where: {userId: req.userData.UserId, teamId: team.id},
|
||||
}
|
||||
if(team.banned) {
|
||||
res.status(200)
|
||||
res.json({success: false})
|
||||
}
|
||||
let teamJoinTest = await TeamMembers.findOne(queryObj3)
|
||||
if (teamJoinTest) {
|
||||
let isAuth1 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role1Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth2 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role2Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth3 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role3Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth4 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role4Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth5 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role5Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth6 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role6Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth7 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role7Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth8 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role8Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth9 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role9Id, TeamId: team.id}
|
||||
})
|
||||
let isAuth10 = await TeamRoles.findOne({
|
||||
where: {id: req.body.Role10Id, TeamId: team.id}
|
||||
})
|
||||
user.update({RoleId: isAuth1.id, Role2Id: isAuth2.id, Role3Id: isAuth3.id, Role4Id: isAuth4.id, Role5Id: isAuth5.id, Role6Id: isAuth6.id, Role7Id: isAuth7.id, Role8Id: isAuth8.id, Role9Id: isAuth9.id, Role10Id: isAuth10.id })
|
||||
} else if (!teamJoinTest) {
|
||||
res.status(400)
|
||||
res.json({success: false})
|
||||
}
|
||||
} else {
|
||||
throw Errors.teamDoesNotExist
|
||||
}
|
||||
} catch (e) { next(e) }
|
||||
})
|
||||
|
||||
router.put('/:username/invites/create', auth, async(req, res, next) => {
|
||||
try {
|
||||
let team = await Team.findOne({
|
||||
|
@ -577,18 +733,84 @@ try {
|
|||
return el !== null;
|
||||
});
|
||||
if(team && otherThanNull) {
|
||||
let create = await TeamInvite.create({
|
||||
maxUses: req.body.maxUses,
|
||||
RoleId: req.body.RoleId,
|
||||
TeamId: team.id,
|
||||
UserId: req.userData.UserId,
|
||||
code: crypto.randomBytes(20).toString('hex')
|
||||
let isAuthMem = await TeamMembers.findOne({
|
||||
where: {UserId: req.userData.UserId, TeamId: team.id}
|
||||
});
|
||||
if(!isAuthMem) {
|
||||
throw Errors.notInTeam
|
||||
}
|
||||
let isAuthRole = await TeamMemberRole.findOne({
|
||||
where: {UserId: req.userData.UserId, TeamId: team.id}
|
||||
})
|
||||
let createJSON = create.toJSON()
|
||||
res.status(200)
|
||||
res.json(createJSON)
|
||||
let isAuth1 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.RoleId, administrator: true}
|
||||
})
|
||||
let isAuth2 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role2Id, administrator: true}
|
||||
})
|
||||
let isAuth3 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role3Id, administrator: true}
|
||||
})
|
||||
let isAuth4 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role4Id, administrator: true}
|
||||
})
|
||||
let isAuth5 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role5Id, administrator: true}
|
||||
})
|
||||
let isAuth6 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role6Id, administrator: true}
|
||||
})
|
||||
let isAuth7 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role7Id, administrator: true}
|
||||
})
|
||||
let isAuth8 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role8Id, administrator: true}
|
||||
})
|
||||
let isAuth9 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role9Id, administrator: true}
|
||||
})
|
||||
let isAuth10 = await TeamRoles.findOne({
|
||||
where: {id: isAuthRole.Role10Id, administrator: true}
|
||||
})
|
||||
const allowArray = [
|
||||
isAuth1,
|
||||
isAuth2,
|
||||
isAuth3,
|
||||
isAuth4,
|
||||
isAuth5,
|
||||
isAuth6,
|
||||
isAuth7,
|
||||
isAuth8,
|
||||
isAuth9,
|
||||
isAuth10
|
||||
]
|
||||
let otherThanNullAdmin = allowArray.some(function (el) {
|
||||
return el !== null;
|
||||
});
|
||||
if(otherThanNullAdmin) {
|
||||
let create = await TeamInvite.create({
|
||||
maxUses: req.body.maxUses,
|
||||
RoleId: req.body.RoleId,
|
||||
TeamId: team.id,
|
||||
UserId: req.userData.UserId,
|
||||
code: cryptoRandomString({length:8, type: "alphanumeric"})
|
||||
})
|
||||
let createJSON = create.toJSON()
|
||||
res.status(200)
|
||||
res.json(createJSON)
|
||||
} else {
|
||||
let create = await TeamInvite.create({
|
||||
maxUses: req.body.maxUses,
|
||||
TeamId: team.id,
|
||||
UserId: req.userData.UserId,
|
||||
code: cryptoRandomString({length:8, type: "alphanumeric"})
|
||||
})
|
||||
let createJSON = create.toJSON()
|
||||
res.status(200)
|
||||
res.json(createJSON)
|
||||
}
|
||||
} else {
|
||||
throw Errors.teamDoesNotExist
|
||||
throw Errors.inviteDenied
|
||||
}
|
||||
} catch (e) { next(e) }
|
||||
})
|
||||
|
|
|
@ -64,9 +64,45 @@ router.post('/', postLimiter, auth, async(req, res, next) => {
|
|||
let thread = await Thread.create({
|
||||
name: req.body.name
|
||||
})
|
||||
await thread.increment('postsCount')
|
||||
|
||||
await thread.setCategory(category)
|
||||
await thread.setUser(user)
|
||||
user = await User.findOne({ where: {
|
||||
username: req.userData.username
|
||||
}})
|
||||
|
||||
|
||||
if(req.body.replyingToId) {
|
||||
let replyingToPost1 = Post.findByPk(
|
||||
req.body.replyingToId, { include: [Thread, { model: User, attributes: ['username'] }] }
|
||||
)
|
||||
console.log(replyingToPost1)
|
||||
replyingToPost = await Post.getReplyingToPost(
|
||||
req.body.replyingToId, thread, replyingToPost1
|
||||
)
|
||||
|
||||
var post = await Post.create({ content: req.body.content, postNumber: thread.postsCount })
|
||||
|
||||
await post.setReplyingTo(replyingToPost)
|
||||
await replyingToPost.addReplies(post)
|
||||
|
||||
let replyNotification = await Notification.createPostNotification({
|
||||
usernameTo: replyingToPost.User.username,
|
||||
userFrom: user,
|
||||
type: 'reply',
|
||||
post: post
|
||||
})
|
||||
await replyNotification.emitNotificationMessage(
|
||||
req.app.get('io-users'),
|
||||
req.app.get('io')
|
||||
)
|
||||
} else {
|
||||
var post = await Post.create({ content: req.body.content, postNumber: thread.postsCount })
|
||||
}
|
||||
|
||||
await post.setUser(user)
|
||||
await post.setThread(thread)
|
||||
|
||||
res.json(await thread.reload({
|
||||
include: [
|
||||
|
|
Loading…
Reference in New Issue