0.177-prerelease (UPGRADE FROM SEQUELIZE V3 to V5, REWRITE MODELS)

This commit is contained in:
Troplo 2020-11-22 17:48:11 +11:00
parent 27babaf337
commit f9d0e9ae5c
52 changed files with 771 additions and 1164 deletions

View File

@ -2,8 +2,8 @@ let Type = require('../lib/validation/type');
let validationError = require('../lib/errors/validationError');
let {
User,
Conversation,
Message,
Conversation,
Message,
UserConversation,
Sequelize
} = require('../models');
@ -18,7 +18,7 @@ exports.create = async function (userIds, name) {
let users;
userIdsSet.forEach(id => {
userPromises.push(User.findById(id));
userPromises.push(User.findByPk(id));
});
users = (await Promise.all(userPromises)).filter(user => user !== null);
@ -156,7 +156,7 @@ exports.get = async function (userId, conversationId, page) {
offset = 0;
}
let conversation = await Conversation.findById(conversationId, {
let conversation = await Conversation.findByPk(conversationId, {
include: [
{
model: User,
@ -191,7 +191,7 @@ exports.get = async function (userId, conversationId, page) {
};
exports.getUserIds = async function (conversationId) {
let conversation = await Conversation.findById(conversationId, {
let conversation = await Conversation.findByPk(conversationId, {
include: [{ model: User }]
});
@ -222,10 +222,10 @@ exports.updateLastRead = async function (conversationId, userId) {
};
exports.updateName = async function (conversationId, userId, name) {
let conversation = await Conversation.findById(conversationId, {
let conversation = await Conversation.findByPk(conversationId, {
include: [{ model: User }]
});
if(
!conversation ||
conversation.Users.find(u => u.id === userId) === undefined
@ -240,4 +240,4 @@ exports.updateName = async function (conversationId, userId, name) {
});
return true;
};
};

View File

@ -10,7 +10,7 @@ let { Message, User, Conversation, Sequelize } = require('../models');
exports.create = async function (params) {
let { content, userId, conversationId } = params;
let user = await User.findById(userId);
let user = await User.findByPk(userId);
if(!user) {
throw validationError({
message: 'User does not exist',
@ -18,7 +18,7 @@ exports.create = async function (params) {
});
}
let conversation = await Conversation.findById(conversationId, {
let conversation = await Conversation.findByPk(conversationId, {
include: [{
model: User,
where: { id: userId }
@ -37,4 +37,4 @@ exports.create = async function (params) {
await Conversation.update({ updatedAt: new Date() }, { where: { id: conversationId } });
return message;
}
}

View File

@ -11,7 +11,7 @@ exports.create = async function (username , password) {
};
exports.get = async function (userId) {
let user = await User.findById(userId, {
let user = await User.findByPk(userId, {
attributes: { exclude: ['hash'] }
});
@ -48,7 +48,7 @@ exports.getAllBeginningWith = async function (username) {
}
exports.login = async function (username, password) {
let user = await User.findById({
let user = await User.findByPk({
where: { username }
});
@ -73,4 +73,4 @@ exports.login = async function (username, password) {
});
}
}
};
};

View File

@ -47,7 +47,7 @@
'👶' , '👦' , '👧' , '👨' , '👩' , '👱‍♀️' , '👱' , '👴' , '👵' , '👲' , '👳‍♀️' , '👳' , '👮‍♀️' , '👮', '💁', '💁‍♂️', '🙅', '🙅‍♂️', '🙆', '🙆‍♂️', '🙋', '🙋‍♂️', '💃', '🕺', '👯', '👯‍♂️', '🚶‍♀️', '🚶', '🏃‍♀️'
]},
{ title: 'animals', emojis: [
'🐶' , '🐱' , '🐭' , '🐹' , '🐰' , '🦊' , '🐻' , '🐼' , '🐨' , '🐯' , '🦁' , '🐮' , '🐷' , '🐽' , '🐸' , '🐵' , '🙊' , '🙉' , '🙊' , '🐒' , '🐔' , '🐧' , '🐦' , '🐤' , '🐣' , '🐥' , '🦆' , '🦅' , '🦉' , '🦇' , '🐺' , '🐗' , '🐴' , '🦄' , '🐝' , '🐛' , '🦋' , '🐌' , '🐞' , '🐜' , '🕷' , '🐢' , '🐍'
'🐶' , '🐱' , '🐭' , '🐹' , '🐰' , '🦊' , '🐻' , '🐼' , '🐨' , '🐯' , '🦁' , '🐮' , '🐷' , '🐽' , '🐸' , '🐵' , '🙊' , '🙉', '🐒' , '🐔' , '🐧' , '🐦' , '🐤' , '🐣' , '🐥' , '🦆' , '🦅' , '🦉' , '🦇' , '🐺' , '🐗' , '🐴' , '🦄' , '🐝' , '🐛' , '🦋' , '🐌' , '🐞' , '🐜' , '🕷' , '🐢' , '🐍'
]},
]
}

View File

@ -15,13 +15,6 @@
:class='{"post__remove_icon--show": showSelect && !post.removed}'
@click.stop='toggleSelected'
/>
<modal-window v-model='showShareModal' @click.stop='() => {}'>
<div slot='main'>
<p>Copy this URL to share the post</p>
<fancy-input placeholder='Post URL' :value='postURL' width='100%'></fancy-input>
</div>
<button slot='footer' class='button button--modal' @click.stop='setShareModalState(false)'>OK</button>
</modal-window>
<report-post-modal v-model='showReportPostModal' :post-id='post.id'></report-post-modal>
@ -70,8 +63,6 @@
</template>
<script>
import ModalWindow from './ModalWindow'
import FancyInput from './FancyInput'
import ReplyingTo from './ReplyingTo'
import ReportPostModal from './ReportPostModal'
import AvatarIcon from './AvatarIcon'
@ -88,8 +79,6 @@ export default {
'allowQuote'
],
components: {
ModalWindow,
FancyInput,
ReplyingTo,
ReportPostModal,
AvatarIcon

View File

@ -177,7 +177,7 @@
this.axios
.delete(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'forums/post/' + this.removePostObj.report.Post.id)
.then(() => {
return this.axios.delete(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'users/report/post/' + this.removePostObj.report.id)
return this.axios.delete(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'users/report/' + this.removePostObj.report.id)
})
.then(() => {
this.reports.splice(this.removePostObj.index, 1)

View File

@ -224,9 +224,6 @@ export default {
this.posts = res.data.userWalls
this.nextPostsCount = res.data.meta.nextPostsCount
})
.catch((e) => {
AjaxErrorHandler(this.$store)(e)
})
logger('userWall', this.$route.params.username)
},

View File

@ -10,65 +10,58 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.BOOLEAN,
defaultValue: false
},
type: DataTypes.ENUM('mention', 'thread update', 'reply')
}, {
classMethods: {
associate (models) {
Notification.hasOne(models.PostNotification)
Notification.belongsTo(models.User)
},
filterMentions (mentions) {
//If mentions is not an array of strings
if(!Array.isArray(mentions) || mentions.filter(m => typeof m !== 'string').length) {
throw Errors.sequelizeValidation(sequelize, {
error: 'mentions must be an array of strings',
value: mentions
})
}
return mentions.filter((mention, pos, self) => {
return self.indexOf(mention) === pos
})
},
//Props fields: userFrom, usernameTo, post, type
async createPostNotification (props) {
let { PostNotification, User, Post } = sequelize.models
let userTo = await User.findOne({ where: { username: props.usernameTo } })
if(!userTo) return null
let notification = await Notification.create({ type: props.type })
let postNotification = await PostNotification.create()
await postNotification.setUser(props.userFrom)
await postNotification.setPost(props.post)
await notification.setPostNotification(postNotification)
await notification.setUser(userTo)
let reloadedNotification = await notification.reload({
include: [{
model: PostNotification,
include: [Post, { model: User, attributes: ['createdAt', 'username', 'color'] }]
}]
})
return reloadedNotification
}
},
instanceMethods: {
async emitNotificationMessage (ioUsers, io) {
let User = sequelize.models.User
let user = await User.findById(this.UserId)
if(ioUsers[user.username]) {
console.log(ioUsers)
io.to(ioUsers[user.username])
.emit('notification', this.toJSON())
}
}
}
type: DataTypes.ENUM('mention', 'thread update', 'reply')
})
Notification.associate = function (models) {
Notification.hasOne(models.PostNotification)
Notification.belongsTo(models.User)
}
Notification.filterMentions = function (mentions) {
//If mentions is not an array of strings
if(!Array.isArray(mentions) || mentions.filter(m => typeof m !== 'string').length) {
throw Errors.sequelizeValidation(sequelize, {
error: 'mentions must be an array of strings',
value: mentions
})
}
return mentions.filter((mention, pos, self) => {
return self.indexOf(mention) === pos
})
}
Notification.createPostNotification = function (props) {
let { PostNotification, User, Post } = sequelize.models
let userTo = User.findOne({ where: { username: props.usernameTo } })
if(!userTo) return null
let notification = Notification.create({ type: props.type })
let postNotification = PostNotification.create()
postNotification.setUser(props.userFrom)
postNotification.setPost(props.post)
notification.setPostNotification(postNotification)
notification.setUser(userTo)
let reloadedNotification = notification.reload({
include: [{
model: PostNotification,
include: [Post, { model: User, attributes: ['createdAt', 'username', 'color'] }]
}]
})
return reloadedNotification
}
Notification.prototype.emitNotificationMessage = function (ioUsers, io) {
let User = sequelize.models.User
let user = User.findByPk(this.UserId)
if(ioUsers[user.username]) {
console.log(ioUsers)
io.to(ioUsers[user.username])
.emit('notification', this.toJSON())
}
}
return Notification
}
}

View File

@ -49,65 +49,61 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
classMethods: {
associate (models) {
Ban.belongsTo(models.User)
},
async getBanInstance (username) {
let user = await sequelize.models.User.findOne({ where: { username } })
let ban = await Ban.findOne({ where: { UserId: user.id } })
return ban
},
async ReadOnlyMode (username) {
let ban = await this.getBanInstance(username)
if(ban && ban.ReadOnlyMode) {
throw Errors.sequelizeValidation(sequelize.Sequelize, {
error: 'You have been set into Read Only mode by an Administrator (aka you\'re banned), Reason: "' + ban.message + '" If you feel like this ban is false, visit /banned' || 'You have been set into Read Only mode by an Administrator. If you would like to object to this ban, visit /banned'
})
} else {
return false
}
},
async isIpBanned (ip, username) {
let { User, Ip } = sequelize.models
if(username) {
let user = await User.findOne({ where: {
username
}})
if(user && user.admin) return false
}
let users = await User.findAll({
include: [{
model: Ip,
where: { ip }
}]
})
if(!users.length) return false
let ban = await Ban.findOne({ where: {
UserId: {
$in: users.map(u => u.id)
},
ipBanned: true
} })
if(ban) {
throw Errors.sequelizeValidation(sequelize.Sequelize, {
error: ban.message ||
'This IP has been banned from creating accounts or logging in'
})
} else {
return false
}
}
}
})
Ban.associate = function (models) {
Ban.belongsTo(models.User)
}
Ban.getBanInstance = function (userid) {
let ban = Ban.findOne({ where: { UserId: userid } })
return ban
}
Ban.isIpBanned = function (ip, username) {
let { User, Ip } = sequelize.models
if(username) {
let user = User.findOne({ where: {
username
}})
if(user && user.admin) return false
}
let users = User.findAll({
include: [{
model: Ip,
where: { ip }
}]
})
if(!users.length) return false
let ban = Ban.findOne({ where: {
UserId: {
$in: users.map(u => u.id)
},
ipBanned: true
} })
if(ban) {
throw Errors.sequelizeValidation(sequelize.Sequelize, {
error: ban.message ||
'This IP has been banned from creating accounts or logging in'
})
} else {
return false
}
}
Ban.ReadOnlyMode = function (username) {
let ban = this.getBanInstance(username)
if(ban && ban.ReadOnlyMode) {
throw Errors.sequelizeValidation(sequelize.Sequelize, {
error: 'You have been set into Read Only mode by an Administrator (aka you\'re banned), Reason: "' + ban.message + '" If you feel like this ban is false, visit /banned' || 'You have been set into Read Only mode by an Administrator. If you would like to object to this ban, visit /banned'
})
} else {
return false
}
}
return Ban
}

View File

@ -11,6 +11,7 @@ module.exports = (sequelize, DataTypes) =>{
UpdatedAt: DataTypes.DATE,
}, {
// Other model options go here
// LEGACY, FOR V3, ASSOCIATIONS AND INSTANCE METHODS GO ABOVE RETURN <MODEL> IN V5
});
return bannedUsernames;
}
}

View File

@ -60,9 +60,7 @@ module.exports = (sequelize, DataTypes) => {
}
},
classMethods: {
associate (models) {
Category.hasMany(models.Thread)
},
// OLD
async AdminOnlyFunc(user) {
if(Category && Category.AdminOnly && !user.admin) {
@ -75,6 +73,8 @@ module.exports = (sequelize, DataTypes) => {
},
}
})
Category.associate = function (models) {
Category.hasMany(models.Thread)
}
return Category
}

View File

@ -57,14 +57,10 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
classMethods: {
associate(models) {
Inventory.belongsTo(models.User, {through: 'User'})
Inventory.belongsTo(models.Item)
}
}
}
)
})
Inventory.associate = function (models) {
Inventory.belongsTo(models.User, {through: 'User'})
Inventory.belongsTo(models.Item)
}
return Inventory
}

View File

@ -6,26 +6,23 @@ module.exports = (sequelize, DataTypes) => {
isIP: true
}
}
}, {
classMethods: {
associate (models) {
Ip.belongsToMany(models.User, { through: 'UserIp' })
},
async createIfNotExists (ipAddress, user) {
let existingIp = await Ip.findOne({
where: { ip: ipAddress },
include: [{
model: sequelize.models.User,
where: { id: user.id }
}]
})
if(!existingIp) {
let ip = await Ip.create({ ip: ipAddress })
await ip.addUser(user)
}
}
}
})
Ip.associate = function (models) {
Ip.belongsToMany(models.User, { through: 'UserIp' })
}
Ip.createIfNotExists = function (ipAddress, user) {
let existingIp = Ip.findOne({
where: { ip: ipAddress },
include: [{
model: sequelize.models.User,
where: { id: user.id }
}]
})
if(!existingIp) {
let ip = Ip.create({ ip: ipAddress })
ip.addUser(user)
}
}
return Ip
}
}

View File

@ -132,39 +132,6 @@ module.exports = (sequelize, DataTypes) => {
default: "No Marketplace item description provided"
}
}, {
instanceMethods: {
},
classMethods: {
associate (models) {
Item.belongsTo(models.ItemCategory)
Item.belongsTo(models.User, {through: 'User'})
},
async canBeUser (passkey) {
let { User, PassKey } = sequelize.models
if(User) {
if(PassKey) {
let passkey = await PassKey.findOne({ where: { passkey } })
if(passkey && PassKey.isValid()) {
await passkey.destroy()
return true
} else {
throw Errors.invalidPassKey
}
} else {
throw Errors.sequelizeValidation(sequelize, {
error: 'Invalid PassKey',
path: 'passkey'
})
}
} else {
return true
}
}
},
hooks: {
async afterValidate(user, options) {
if(user.changed('hash') && user.hash.length <= 50) {
@ -176,6 +143,9 @@ module.exports = (sequelize, DataTypes) => {
}
}
})
Item.associate = function (models) {
Item.belongsTo(models.ItemCategory)
Item.belongsTo(models.User, {through: 'User'})
}
return Item
}

View File

@ -35,13 +35,10 @@ module.exports = (sequelize, DataTypes) => {
category.value = underscored
}
}
},
classMethods: {
associate (models) {
ItemCategory.hasMany(models.Item)
}
}
})
}})
ItemCategory.associate = function (models) {
ItemCategory.hasMany(models.Item)
}
return ItemCategory
}

View File

@ -38,6 +38,17 @@ module.exports = (sequelize, DataTypes) => {
}
}
})
Log.associate = function (models) {
//Resources corresponding to the route
//I.e. route userPosts and UserId 3
//Corresponds to /user/[username for id 3]/posts
Log.belongsTo(models.Thread)
Log.belongsTo(models.User)
//Rather than id corresponding to the route resource
//Id corresponding to the user behind the session
//(If session is from logged in user)
Log.belongsTo(models.User, { as: 'SessionUser' })
}
return Log
}

View File

@ -17,13 +17,9 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
classMethods: {
associate (models) {
PollAnswer.hasMany(models.PollVote)
}
}
})
PollAnswer.associate = function (models) {
PollAnswer.hasMany(models.PollVote)
}
return PollAnswer
}
}

View File

@ -17,15 +17,12 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
classMethods: {
associate (models) {
PollQuestion.belongsTo(models.User)
PollQuestion.hasMany(models.PollAnswer)
PollQuestion.hasMany(models.PollVote)
}
}
})
PollQuestion.associate = function (models) {
PollQuestion.belongsTo(models.User)
PollQuestion.hasMany(models.PollAnswer)
PollQuestion.hasMany(models.PollVote)
}
return PollQuestion
}
}

View File

@ -1,15 +1,12 @@
module.exports = (sequelize, DataTypes) => {
let Sequelize = sequelize.Sequelize
let PollVote = sequelize.define('PollVote', {}, {
classMethods: {
associate (models) {
PollVote.belongsTo(models.PollAnswer)
PollVote.belongsTo(models.PollQuestion)
PollVote.belongsTo(models.User)
}
}
})
let PollVote = sequelize.define('PollVote', {})
PollVote.associate = function (models) {
PollVote.belongsTo(models.PollAnswer)
PollVote.belongsTo(models.PollQuestion)
PollVote.belongsTo(models.User)
}
return PollVote
}
}

View File

@ -94,59 +94,52 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.BOOLEAN,
defaultValue: false
}
}, {
instanceMethods: {
getReplyingTo () {
return Post.findByPrimary(this.replyId)
},
setReplyingTo (post) {
return post.getUser().then(user => {
return this.update({ replyingToUsername: user.username, replyId: post.id })
})
}
},
classMethods: {
associate (models) {
Post.belongsTo(models.User)
Post.belongsTo(models.Thread)
Post.hasMany(models.Post, { as: 'Replies', foreignKey: 'replyId' })
Post.belongsToMany(models.User, { as: 'Likes', through: 'user_post' })
Post.hasMany(models.Report, { foreignKeyConstraint: true, onDelete: 'CASCADE', hooks: true })
},
includeOptions () {
let models = sequelize.models
return [
{ model: models.User, attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
{ model: models.User, as: 'Likes', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
{ model: models.Thread, include: [models.Category]} ,
{
model: models.Post, as: 'Replies', include:
[{ model: models.User, attributes: ['username', 'id', 'color', 'picture'] }]
}
]
},
async getReplyingToPost (id, thread) {
let { Thread, User } = sequelize.models
let replyingToPost = await Post.findById(
id,
{ include: [Thread, { model: User, attributes: ['username'] }] }
)
if(!replyingToPost) {
throw Errors.invalidParameter('replyingToId', 'post does not exist')
} else if(replyingToPost.Thread.id !== thread.id) {
throw Errors.invalidParameter('replyingToId', 'replies must be in same thread')
} else if (replyingToPost.removed) {
throw Errors.postRemoved
} else {
return replyingToPost
}
}
}
})
Post.associate = function (models) {
Post.belongsTo(models.User)
Post.belongsTo(models.Thread)
Post.hasMany(models.Post, { as: 'Replies', foreignKey: 'replyId' })
Post.belongsToMany(models.User, { as: 'Likes', through: 'user_post' })
return Post
Post.hasMany(models.Report, { foreignKeyConstraint: true, onDelete: 'CASCADE', hooks: true })
}
Post.includeOptions = function () {
let models = sequelize.models
return [
{ model: models.User, attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
{ model: models.User, as: 'Likes', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
{ model: models.Thread, include: [models.Category]} ,
{
model: models.Post, as: 'Replies', include:
[{ model: models.User, attributes: ['username', 'id', 'color', 'picture'] }]
}
]
}
Post.prototype.getReplyingToPost = function (id, thread) {
let { Thread, User } = sequelize.models
let replyingToPost = Post.findByPk(
id,
{ include: [Thread, { model: User, attributes: ['username'] }] }
)
if(!replyingToPost) {
throw Errors.invalidParameter('replyingToId', 'post does not exist')
} else if(replyingToPost.Thread.id !== thread.id) {
throw Errors.invalidParameter('replyingToId', 'replies must be in same thread')
} else if (replyingToPost.removed) {
throw Errors.postRemoved
} else {
return replyingToPost
}
}
Post.prototype.setReplyingTo = function (post) {
return post.getUser().then(user => {
return this.update({ replyingToUsername: user.username, replyId: post.id })
})
}
Post.prototype.getReplyingTo = function () {
return Post.findByPrimary(this.replyId)
}
return Post
}

View File

@ -8,6 +8,10 @@ module.exports = (sequelize, DataTypes) => {
}
}
})
PostNotification.associate = function (models) {
PostNotification.belongsTo(models.User)
PostNotification.belongsTo(models.Post)
PostNotification.belongsTo(models.Notification)
}
return PostNotification
}
}

View File

@ -10,34 +10,31 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
classMethods: {
associate (models) {
Report.belongsTo(models.User, { as: 'FlaggedByUser' })
Report.belongsTo(models.Post)
},
InvalidPostId (value) {
return new sequelize.ValidationError('Post ID is not valid', [
new sequelize.ValidationErrorItem(
'Post id is not valid',
'Validation error',
'postId',
value
)
])
},
InvalidUserId (value) {
return new sequelize.ValidationError('User ID is not valid', [
new sequelize.ValidationErrorItem(
'User ID is not valid',
'Validation error',
'userId',
value
)
])
}
}
})
Report.associate = function (models) {
Report.belongsTo(models.User, { as: 'FlaggedByUser' })
Report.belongsTo(models.Post)
}
Report.InvalidPostId = function (value) {
return new sequelize.ValidationError('Post ID is not valid', [
new sequelize.ValidationErrorItem(
'Post id is not valid',
'Validation error',
'postId',
value
)
])
}
Report.InvalidUserId = function (value) {
return new sequelize.ValidationError('User ID is not valid', [
new sequelize.ValidationErrorItem(
'User ID is not valid',
'Validation error',
'userId',
value
)
])
}
return Report
}

View File

@ -72,7 +72,7 @@ module.exports = (sequelize, DataTypes) => {
return Settings.upsert(values)
},
get () {
return Settings.findById(1)
return Settings.findByPk(1)
}
}
})

View File

@ -123,122 +123,38 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
instanceMethods: {
async updateUsername (username, password) {
if(typeof username !== 'string') {
throw new sequelize.ValidationError('Please enter your new username')
}
if(typeof password !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
let correctPassword = await bcrypt.compare(password, this.hash)
if(correctPassword) {
await this.update({username: username, koins: this.koins - 200})
} else {
throw Errors.invalidLoginCredentials
}
},
async getMeta (limit) {
let Post = sequelize.models.Post
let meta = {}
let nextId = await pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `user/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Posts, limit,
{ UserId: this.id },
true
)
}
return meta
},
async getWallMeta (limit) {
let Post = sequelize.models.teamWall
let meta = {}
let nextId = await pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
``
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Post, limit,
{ Post: this.id },
true
)
}
return meta
}
},
classMethods: {
associate (models) {
Team.hasMany(models.teamWall)
Team.hasMany(models.TeamMembers)
},
includeOptions (from, limit) {
let models = sequelize.models
let options = models.Post.includeOptions()
return [{
model: models.Post,
include: options,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
includeWallOptions (from, limit) {
let models = sequelize.models
return [{
model: models.teamWall,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
async canBeUser (passkey) {
let { User, PassKey } = sequelize.models
if(User) {
if(PassKey) {
let passkey = await PassKey.findOne({ where: { passkey } })
if(passkey && PassKey.isValid()) {
await passkey.destroy()
return true
} else {
throw Errors.invalidPassKey
}
} else {
throw Errors.sequelizeValidation(sequelize, {
error: 'Invalid PassKey',
path: 'passkey'
})
}
} else {
return true
}
}
}
})
Team.associate = function (models) {
Team.hasMany(models.teamWall)
Team.hasMany(models.TeamMembers)
}
Team.prototype.updateUsername = function(username) {
if(typeof username !== 'string') {
throw new sequelize.ValidationError('Please enter your new username')
}
this.update({username: username, koins: this.koins - 200})
}
Team.getWallMeta = function (limit) {
let Post = sequelize.models.teamWall
let meta = {}
let nextId = pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
``
meta.nextPostsCount = pagination.getNextCount(
Post, this.Post, limit,
{ Post: this.id },
true
)
}
return meta
}
return Team
}

View File

@ -79,44 +79,39 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.BOOLEAN,
defaultValue: false
}
}, {
instanceMethods: {
async getMeta(limit) {
let Post = sequelize.models.userWall
let meta = {}
let nextId = await pagination.getNextIdDesc(userWall, {fromUserId: this.id}, this.Posts)
if (nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `wall/show/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Posts, limit,
{fromUserId: this.id},
true
)
}
return meta
}
},
classMethods: {
associate (models) {
teamWall.belongsTo(models.User, { as: 'fromUser' })
},
includeOptions () {
let models = sequelize.models
return [
{ model: models.User, as: 'fromUser', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
]
}
},
})
teamWall.associate = function (models) {
teamWall.belongsTo(models.User, { as: 'fromUser' })
}
teamWall.includeOptions = function () {
let models = sequelize.models
return [
{ model: models.User, as: 'fromUser', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
]
}
teamWall.prototype.getMeta = function (limit) {
let Post = sequelize.models.userWall
let meta = {}
let nextId = pagination.getNextIdDesc(userWall, {fromUserId: this.id}, this.Posts)
if (nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `wall/show/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = pagination.getNextCount(
Post, this.Posts, limit,
{fromUserId: this.id},
true
)
}
return meta
}
return teamWall
}
}

View File

@ -39,31 +39,28 @@ module.exports = (sequelize, DataTypes) => {
allowNull: true,
defaultValue: 0,
default: 0
}
}, {
classMethods: {
associate(models) {
TeamInvite.belongsTo(models.Team)
TeamInvite.belongsTo(models.User)
},
includeOptions() {
let models = sequelize.models
return [
{model: models.User, as: 'User', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
{model: models.TeamRoles},
]
}
},
instanceMethods: {
async killInvite(invite) {
await this.destroy()
},
async createInvite(team) {
await this.create({TeamId: team.id, RoleId: team.RoleId, maxUses: team.maxUses})
}
UserId: {
type: DataTypes.BIGINT
}
})
TeamInvite.associate = function (models) {
TeamInvite.belongsTo(models.Team)
TeamInvite.belongsTo(models.User)
}
TeamInvite.includeOptions = function () {
let models = sequelize.models
return [
{model: models.User, as: 'User', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
{model: models.TeamRoles},
]
}
TeamInvite.prototype.killInvite = function (invite) {
this.destroy()
}
TeamInvite.prototype.createInvite = function (team) {
this.create({TeamId: team.id, RoleId: team.RoleId, maxUses: team.maxUses})
}
return TeamInvite
}

View File

@ -56,38 +56,32 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.DATE,
allowNull: false
}
}, {
classMethods: {
associate(models) {
TeamMemberRole.belongsTo(models.User)
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role2'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role3'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role4'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role5'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role6'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role7'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role8'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role9'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role10'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Team' })
},
includeOptions() {
let models = sequelize.models
return [
{model: models.User, as: 'User', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
{model: models.TeamRoles},
]
}
},
instanceMethods: {
async leaveTeam() {
await this.destroy()
}
}
})
TeamMemberRole.associate = function (models) {
TeamMemberRole.belongsTo(models.User)
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role2'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role3'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role4'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role5'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role6'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role7'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role8'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role9'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Role10'})
TeamMemberRole.belongsTo(models.TeamRoles, { as: 'Team' })
}
TeamMemberRole.includeOptions = function () {
let models = sequelize.models
return [
{model: models.User, as: 'User', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
{model: models.TeamRoles},
]
}
TeamMemberRole.prototype.leaveTeam = function () {
this.destroy()
}
return TeamMemberRole
}

View File

@ -19,25 +19,20 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.JSON,
defaultValue: "1"
},
}, {
classMethods: {
associate (models) {
TeamMembers.belongsTo(models.User)
// TeamMembers.belongsTo(models.TeamMemberRole)
},
includeOptions () {
let models = sequelize.models
return [
{ model: models.User, as: 'user', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
]
}
}, instanceMethods: {
async leaveTeam() {
await this.destroy()
}
}
})
TeamMembers.associate = function (models) {
TeamMembers.belongsTo(models.User)
}
TeamMembers.includeOptions = function () {
let models = sequelize.models
return [
{ model: models.User, as: 'user', attributes: ['username', 'createdAt', 'id', 'color', 'picture']},
]
}
TeamMembers.prototype.leaveTeam = function () {
this.destroy()
}
return TeamMembers
}
}

View File

@ -62,109 +62,11 @@ module.exports = (sequelize, DataTypes) => {
teamId: {
type: DataTypes.BIGINT
}
}, {
instanceMethods: {
async getMeta (limit) {
let Post = sequelize.models.Post
let meta = {}
let nextId = await pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `user/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Posts, limit,
{ UserId: this.id },
true
)
}
return meta
},
async getWallMeta (limit) {
let Post = sequelize.models.userWall
let meta = {}
let nextId = await pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
``
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Post, limit,
{ Post: this.id },
true
)
}
return meta
}
},
classMethods: {
associate (models) {
// TeamRoles.hasMany(models.User)
// TeamRoles.hasMany(models.TeamMemberRole, { as: 'team'})
TeamRoles.hasMany(models.Team)
//TeamRoles.hasMany(models.Team, {as: 'team'})
},
includeOptions (from, limit) {
let models = sequelize.models
let options = models.Post.includeOptions()
return [{
model: models.Post,
include: options,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
includeWallOptions (from, limit) {
let models = sequelize.models
return [{
model: models.userWall,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
async canBeUser (passkey) {
let { User, PassKey } = sequelize.models
if(User) {
if(PassKey) {
let passkey = await PassKey.findOne({ where: { passkey } })
if(passkey && PassKey.isValid()) {
await passkey.destroy()
return true
} else {
throw Errors.invalidPassKey
}
} else {
throw Errors.sequelizeValidation(sequelize, {
error: 'Invalid PassKey',
path: 'passkey'
})
}
} else {
return true
}
}
}
})
TeamRoles.associate = function (models) {
TeamRoles.hasMany(models.Team)
}
return TeamRoles
}

View File

@ -1,4 +1,5 @@
let urlSlug = require('url-slug')
const { Op } = require("sequelize");
module.exports = (sequelize, DataTypes) => {
let Thread = sequelize.define('Thread', {
@ -45,95 +46,89 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.BOOLEAN,
defaultValue: true
}
}, {
instanceMethods: {
getMeta (limit) {
let meta = {}
})
Thread.associate = function (models) {
Thread.belongsTo(models.User)
Thread.belongsTo(models.Category)
Thread.belongsTo(models.PollQuestion)
Thread.hasMany(models.Post, { foreignKeyConstraint: true, onDelete: 'CASCADE' })
}
Thread.includeOptions = function (from, limit) {
let models = sequelize.models
let posts = this.Posts
let firstPost = posts[0]
let lastPost = posts.slice(-1)[0]
//next url
if(!lastPost || lastPost.postNumber+1 === this.postsCount) {
meta.nextURL = null
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `forums/thread/${this.id}?limit=${limit}&from=${lastPost.postNumber + 1}`
}
//previous url
if(!firstPost || firstPost.postNumber === 0) {
meta.previousURL = null
} else if(firstPost.postNumber - limit < 0) {
meta.previousURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `forums/thread/${this.id}?limit=${firstPost.postNumber}&from=0`
} else {
meta.previousURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `forums/thread/${this.id}?limit=${limit}&from=${firstPost.postNumber - limit}`
}
//remaining posts
if(lastPost === undefined) {
meta.nextPostsCount = 0
meta.previousPostsCount = 0
meta.postsRemaining = 0
} else {
let postsRemaining =
this.postsCount - lastPost.postNumber - 1
meta.postsRemaining = postsRemaining
if(postsRemaining < limit) {
meta.nextPostsCount = postsRemaining
} else {
meta.nextPostsCount = limit
}
if(firstPost.postNumber === 0) {
meta.previousPostsCount = 0
} else if(firstPost.postNumber - limit < 0) {
meta.previousPostsCount = firstPost.postNumber
} else {
meta.previousPostsCount = limit
}
}
return meta
}
},
classMethods: {
associate (models) {
Thread.belongsTo(models.User)
Thread.belongsTo(models.Category)
Thread.belongsTo(models.PollQuestion)
Thread.hasMany(models.Post, { foreignKeyConstraint: true, onDelete: 'CASCADE' })
},
includeOptions (from, limit) {
let models = sequelize.models
return [
{ model: models.User, attributes: ['username', 'createdAt', 'color', 'picture', 'updatedAt', 'id'] },
models.Category,
return [
{ model: models.User, attributes: ['username', 'createdAt', 'color', 'picture', 'updatedAt', 'id'] },
models.Category,
{
model: models.Post,
where: { postNumber: { [Op.gte]: from } },
order: [['id', 'ASC']],
limit,
include: [
{ model: models.Thread, attributes: ['slug'] },
{ model: models.User, as: 'Likes', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
{ model: models.User, attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'admin'] },
{
model: models.Post,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']],
limit,
include: [
{ model: models.Thread, attributes: ['slug'] },
{ model: models.User, as: 'Likes', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
{ model: models.User, attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'admin'] },
{
model: models.Post, as: 'Replies', include:
[{ model: models.User, attributes: ['username', 'id', 'color', 'picture'] }]
}
]
model: models.Post, as: 'Replies', include:
[{ model: models.User, attributes: ['username', 'id', 'color', 'picture'] }]
}
]
}
}
})
]
}
Thread.prototype.getMeta = function (limit) {
let meta = {}
return Thread
let posts = this.Posts
let firstPost = posts[0]
let lastPost = posts.slice(-1)[0]
//next url
if(!lastPost || lastPost.postNumber+1 === this.postsCount) {
meta.nextURL = null
} else {
meta.nextURL =
`/api/v1/forums/thread/${this.id}?limit=${limit}&from=${lastPost.postNumber + 1}`
}
//previous url
if(!firstPost || firstPost.postNumber === 0) {
meta.previousURL = null
} else if(firstPost.postNumber - limit < 0) {
meta.previousURL =
`/api/v1/forums/thread/${this.id}?limit=${firstPost.postNumber}&from=0`
} else {
meta.previousURL =
`/api/v1/forums/thread/${this.id}?limit=${limit}&from=${firstPost.postNumber - limit}`
}
//remaining posts
if(lastPost === undefined) {
meta.nextPostsCount = 0
meta.previousPostsCount = 0
meta.postsRemaining = 0
} else {
let postsRemaining =
this.postsCount - lastPost.postNumber - 1
meta.postsRemaining = postsRemaining
if(postsRemaining < limit) {
meta.nextPostsCount = postsRemaining
} else {
meta.nextPostsCount = limit
}
if(firstPost.postNumber === 0) {
meta.previousPostsCount = 0
} else if(firstPost.postNumber - limit < 0) {
meta.previousPostsCount = firstPost.postNumber
} else {
meta.previousPostsCount = limit
}
}
return meta
}
return Thread
}

View File

@ -247,253 +247,7 @@ module.exports = (sequelize, DataTypes) => {
}
}
}
}, {
instanceMethods: {
async removeKoins(amount) {
if(this.koins >= amount) {
await this.update({koins: this.koins - amount})
} else {
throw Errors.insufficientKoins
}
},
async rand() {
await this.update({ emailToken: cryptoRandomString({length: 250})})
},
async randPasswordReset() {
if(User) {
await this.update({ passwordResetToken: cryptoRandomString({length: 250}), deleteEnabled: true })
} else {
throw Errors.accountDoesNotExist
}
},
async randAccountDelete() {
if(User) {
await this.update({ deleteCode: cryptoRandomString({length: 1024}), deleteEnabled: true})
} else {
throw Errors.accountDoesNotExist
}
},
async emailVerify() {
await this.update({ emailVerified: true })
},
async updatePassword (currentPassword, newPassword) {
if(currentPassword === newPassword) {
throw Errors.passwordSame
} else if(typeof currentPassword !== 'string' || typeof newPassword !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
let correctPassword = await bcrypt.compare(currentPassword, this.hash)
if(correctPassword) {
await this.update({ hash: newPassword })
} else {
throw Errors.invalidLoginCredentials
}
},
async reward () {
let ms = Date.now() - this.lastRewardDate
let dayMs = 1000*60*60*24
//Has less than 1 day passed
//since generating token?
return ms / dayMs < 1
},
async doReward () {
if(User.lastRewardDate) {
if(User.lastRewardDate.reward()) {
throw Errors.invalidToken
} else {
throw Errors.invalidPassKey
}
} else {
console.log("idk")
}
},
async invalidateJWT () {
await this.update({ jwtOffset: this.jwtOffset + 1 })
},
async recoveryUpdatePassword (password) {
if(typeof password !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
await this.update({ hash: password, passwordResetEnabled: false })
},
/* async GenerateJWT() {
const today = new Date();
const expirationDate = new Date(today);
expirationDate.setDate(today.getDate() + 60);
let payload = {
id: this.id,
email: this.email,
username: this.username,
};
return jwt.sign(payload, "AUSDHIASDHAHDAiyrgy3476rty734we6yrgwesyufeyhurfehyrurgty7346ertg645e37t6rgyu", {
expiresIn: parseInt(expirationDate.getTime() / 1000, 10)
});
}, */
async updateEmail (emailCurrentPassword, newEmail) {
if(typeof emailCurrentPassword !== 'string' || typeof newEmail !== 'string') {
throw new sequelize.ValidationError('input must be a string')
}
let correctPassword = await bcrypt.compare(emailCurrentPassword, this.hash)
if(correctPassword) {
await this.update({ email: newEmail, emailVerified: false, emailToken: cryptoRandomString({length: 16})})
} else {
throw Errors.invalidLoginCredentials
}
},
async updateUsername (username, password) {
if(typeof username !== 'string') {
throw new sequelize.ValidationError('Please enter your new username')
}
if(typeof password !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
let correctPassword = await bcrypt.compare(password, this.hash)
if(correctPassword) {
await this.update({username: username, koins: this.koins - 200})
} else {
throw Errors.invalidLoginCredentials
}
},
async comparePassword (password) {
return await bcrypt.compare(password, this.hash)
},
async destroyVerifyPassword (password) {
if(typeof password !== 'string') {
throw Errors.invalidLoginCredentials
}
let correctPassword = await bcrypt.compare(password, this.hash)
if(correctPassword) {
await this.destroy()
} else {
throw Errors.invalidLoginCredentials
}
},
async getMeta (limit) {
let Post = sequelize.models.Post
let meta = {}
let nextId = await pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `user/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Posts, limit,
{ UserId: this.id },
true
)
}
return meta
},
async getWallMeta (limit) {
let Post = sequelize.models.userWall
let meta = {}
let nextId = await pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
``
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Post, limit,
{ Post: this.id },
true
)
}
return meta
}
},
classMethods: {
associate (models) {
User.hasMany(models.Post)
User.hasMany(models.Thread)
User.hasMany(models.userWall)
User.hasMany(models.Inventory)
User.hasMany(models.Transaction)
User.hasMany(models.AuditLog)
User.hasMany(models.Item)
User.belongsToMany(models.Conversation, { through: models.UserConversation })
User.belongsToMany(models.Ip, { through: 'UserIp' })
},
includeOptions (from, limit) {
let models = sequelize.models
let options = models.Post.includeOptions()
return [{
model: models.Post,
include: options,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
includeMarketplaceOptions (from, limit) {
let models = sequelize.models
return [{
model: models.Item,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
includeWallOptions (from, limit) {
let models = sequelize.models
return [{
model: models.userWall,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
},
async canBeUser (passkey) {
let { User, PassKey } = sequelize.models
if(User) {
if(PassKey) {
let passkey = await PassKey.findOne({ where: { passkey } })
if(passkey && PassKey.isValid()) {
await passkey.destroy()
return true
} else {
throw Errors.invalidPassKey
}
} else {
throw Errors.sequelizeValidation(sequelize, {
error: 'Invalid PassKey',
path: 'passkey'
})
}
} else {
return true
}
}
},
hooks: {
}, {hooks: {
async afterValidate(user, options) {
if(user.changed('hash') && user.hash.length <= 50) {
user.hash = await bcrypt.hash(user.hash, 12)
@ -504,6 +258,189 @@ module.exports = (sequelize, DataTypes) => {
}
}
})
User.associate = function (models) {
User.hasMany(models.Post)
User.hasMany(models.Thread)
User.hasMany(models.userWall)
User.hasMany(models.Inventory)
User.hasMany(models.Transaction)
User.hasMany(models.AuditLog)
User.hasMany(models.Item)
User.belongsToMany(models.Conversation, { through: models.UserConversation })
User.belongsToMany(models.Ip, { through: 'UserIp' })
}
User.prototype.getMeta = function (limit) {
let Post = sequelize.models.Post
let meta = {}
let nextId = pagination.getNextIdDesc(Post, { userId: this.id }, this.Posts)
if(nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `user/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = pagination.getNextCount(
Post, this.Posts, limit,
{ UserId: this.id },
true
)
}
return meta
}
User.includeWallOptions = function (from, limit) {
let models = sequelize.models
return [{
model: models.userWall,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
}
User.includeOptions = function (from, limit) {
let models = sequelize.models
let options = models.Post.includeOptions()
return [{
model: models.Post,
include: options,
limit,
where: { postNumber: { $gte: from } },
order: [['id', 'ASC']]
}]
}
User.prototype.comparePassword = function (password) {
return bcrypt.compare(password, this.hash)
}
User.prototype.destroyVerifyPassword = function (password) {
if(typeof password !== 'string') {
throw Errors.invalidLoginCredentials
}
let correctPassword = bcrypt.compare(password, this.hash)
if(correctPassword) {
this.destroy()
} else {
throw Errors.invalidLoginCredentials
}
}
User.prototype.removeKoins = function(amount) {
if(this.koins >= amount) {
this.update({koins: this.koins - amount})
} else {
throw Errors.insufficientKoins
}
}
User.prototype.rand = function() {
this.update({ emailToken: cryptoRandomString({length: 250})})
}
User.prototype.randPasswordReset = function() {
if(User) {
this.update({ passwordResetToken: cryptoRandomString({length: 250}), deleteEnabled: true })
} else {
throw Errors.accountDoesNotExist
}
}
User.prototype.randAccountDelete = function() {
if(User) {
this.update({ deleteCode: cryptoRandomString({length: 1024}), deleteEnabled: true})
} else {
throw Errors.accountDoesNotExist
}
}
User.prototype.emailVerify = function () {
this.update({ emailVerified: true })
}
User.prototype.updatePassword = function (currentPassword, newPassword) {
if(currentPassword === newPassword) {
throw Errors.passwordSame
} else if(typeof currentPassword !== 'string' || typeof newPassword !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
let correctPassword = bcrypt.compare(currentPassword, this.hash)
if(correctPassword) {
this.update({ hash: newPassword })
} else {
throw Errors.invalidLoginCredentials
}
}
User.prototype.reward = function () {
let ms = Date.now() - this.lastRewardDate
let dayMs = 1000*60*60*24
//Has less than 1 day passed
//since generating token?
return ms / dayMs < 1
}
User.prototype.doReward = function () {
if(User.lastRewardDate) {
if(User.lastRewardDate.reward()) {
throw Errors.invalidToken
} else {
throw Errors.invalidPassKey
}
} else {
console.log("idk")
}
}
User.prototype.invalidateJWT = function () {
this.update({ jwtOffset: this.jwtOffset + 1 })
}
User.prototype.recoveryUpdatePassword = function (password) {
if(typeof password !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
this.update({ hash: password, passwordResetEnabled: false })
}
/* User.prototype.GenerateJWT = function () {
const today = new Date();
const expirationDate = new Date(today);
expirationDate.setDate(today.getDate() + 60);
let payload = {
id: this.id,
email: this.email,
username: this.username,
};
return jwt.sign(payload, "AUSDHIASDHAHDAiyrgy3476rty734we6yrgwesyufeyhurfehyrurgty7346ertg645e37t6rgyu", {
expiresIn: parseInt(expirationDate.getTime() / 1000, 10)
});
}, */
User.prototype.updateEmail = function (emailCurrentPassword, newEmail) {
if(typeof emailCurrentPassword !== 'string' || typeof newEmail !== 'string') {
throw new sequelize.ValidationError('input must be a string')
}
let correctPassword = bcrypt.compare(emailCurrentPassword, this.hash)
if(correctPassword) {
this.update({ email: newEmail, emailVerified: false, emailToken: cryptoRandomString({length: 16})})
} else {
throw Errors.invalidLoginCredentials
}
}
User.prototype.updateUsername = function (username, password) {
if(typeof username !== 'string') {
throw new sequelize.ValidationError('Please enter your new username')
}
if(typeof password !== 'string') {
throw new sequelize.ValidationError('Please enter your password')
}
let correctPassword = bcrypt.compare(password, this.hash)
if(correctPassword) {
this.update({username: username, koins: this.koins - 200})
} else {
throw Errors.invalidLoginCredentials
}
}
return User
}

View File

@ -79,44 +79,39 @@ module.exports = (sequelize, DataTypes) => {
type: DataTypes.BOOLEAN,
defaultValue: false
}
}, {
instanceMethods: {
async getMeta(limit) {
let Post = sequelize.models.userWall
let meta = {}
let nextId = await pagination.getNextIdDesc(userWall, {fromUserId: this.id}, this.Posts)
if (nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `wall/show/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = await pagination.getNextCount(
Post, this.Posts, limit,
{fromUserId: this.id},
true
)
}
return meta
}
},
classMethods: {
associate (models) {
userWall.belongsTo(models.User, { as: 'fromUser' })
},
includeOptions () {
let models = sequelize.models
return [
{ model: models.User, as: 'fromUser', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
]
}
},
})
userWall.associate = function (models) {
userWall.belongsTo(models.User, { as: 'fromUser' })
}
userWall.includeOptions = function () {
let models = sequelize.models
return [
{ model: models.User, as: 'fromUser', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
]
}
userWall.prototype.getMeta = function (limit) {
let Post = sequelize.models.userWall
let meta = {}
let nextId = pagination.getNextIdDesc(userWall, {fromUserId: this.id}, this.Posts)
if (nextId === null) {
meta.nextURL = null
meta.nextPostsCount = 0
} else {
meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `wall/show/${this.username}?posts=true&limit=${limit}&from=${nextId - 1}`
meta.nextPostsCount = pagination.getNextCount(
Post, this.Posts, limit,
{fromUserId: this.id},
true
)
}
return meta
}
return userWall
}

View File

@ -65,7 +65,7 @@
"qrcode": "^1.4.4",
"randomcolor": "^0.4.4",
"sendgrid": "^5.2.3",
"sequelize": "3.35.1",
"sequelize": "5.22.3",
"sequelize-cli": "^4.1.1",
"sharp": "^0.26.2",
"simple-rate-limit": "^1.0.0",

View File

@ -54,7 +54,7 @@ router.get('/', auth, async(req, res, next) => {
})
router.delete('/:id', auth, async(req, res, next) => {
try {
let unbanrequest = await UnbanRequest.findById(req.params.id)
let unbanrequest = await UnbanRequest.findByPk(req.params.id)
await report.destroy()
res.json({ success: true })
} catch (e) { next(e) }

View File

@ -33,7 +33,7 @@ router.put('/user/scrub', auth, async(req, res, next) => {
if(!req.userData.admin) {
throw Errors.requestNotAuthorized
}
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
if(req.autosan.body.description === "descscram") {
let user = await User.findOne({ where: {
@ -78,7 +78,7 @@ router.put('/user/modify', auth, async(req, res, next) => {
throw Errors.requestNotAuthorized
}
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
if(req.body.username) {
let user = await User.findOne({ where: {

View File

@ -15,7 +15,7 @@ const Errors = require('../lib/errors')
var randomString = (Math.random().toString(36).substring(2))
router.use(limiter);
router.post("/refresh", limiter, auth, async(req, res, next) => {
User.findById(req.userData.UserId).then(function(selected){
User.findByPk(req.userData.UserId).then(function(selected){
var blendFilePath = "../rendering/avatar.blend";
var imageSavePath = "/usr/share/nginx/html/cdn/user/avatars/full/"+req.userData.UserID+"-"+randomString+".png";
var pythonFilePath = "../rendering/usercontent/"+req.userData.UserID+".py";

View File

@ -61,7 +61,7 @@ router.get('/', auth, async(req, res, next) => {
router.delete('/:ban_id', auth, async(req, res, next) => {
try {
let ban = await Ban.findById(req.params.ban_id)
let ban = await Ban.findByPk(req.params.ban_id)
if(!ban) throw Errors.sequelizeValidation(Sequelize, {
error: 'ban does not exist',
value: req.body.userId

View File

@ -99,7 +99,7 @@ router.get('/:category', async(req, res, next) => {
if(nextId) {
resThreads.meta.nextURL =
process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + `/` + `forums/category/${req.params.category}?&limit=${limit}&from=${nextId - 1}`
`/api/v1/forums/category/${req.params.category}?&limit=${limit}&from=${nextId - 1}`
if(user) {
resThreads.meta.nextURL += '&username=' + user.username
@ -182,7 +182,7 @@ router.put('/:category_id', auth, async(req, res, next) => {
value: id
})
} else {
let ret = await Category.findById(id)
let ret = await Category.findByPk(id)
res.json(ret.toJSON())
}
} catch(e) { next(e) }
@ -190,7 +190,7 @@ router.put('/:category_id', auth, async(req, res, next) => {
router.delete('/:id', auth, async(req, res, next) => {
try {
let category = await Category.findById(req.params.id)
let category = await Category.findByPk(req.params.id)
if(!category) throw Errors.sequelizeValidation(Sequelize, {
error: 'category id does not exist',
value: req.params.id

View File

@ -58,7 +58,7 @@ router.post('/', auth, async(req, res, next) => {
try {
let thread, user
if(req.body.route === 'thread') {
thread = await Thread.findById(req.body.resourceId)
thread = await Thread.findByPk(req.body.resourceId)
if(!thread) throw Errors.sequelizeValidation(Sequelize, {
error: 'thread does not exist',
@ -70,7 +70,7 @@ router.post('/', auth, async(req, res, next) => {
req.body.route === 'userMarketplace' ||
req.body.route === 'userWall'
) {
user = await User.findById(req.body.resourceId)
user = await User.findByPk(req.body.resourceId)
if(!user) throw Errors.sequelizeValidation(Sequelize, {
error: 'User does not exist, or feature isn\'t implemented.',

View File

@ -113,7 +113,7 @@ router.get('/view/:id', async(req, res, next) => {
})
router.get('/purchase/:id', auth, async(req, res, next) => {
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
try {
let queryObj = {
where: {id: req.params.id},

View File

@ -8,7 +8,7 @@ const Errors = require('../lib/errors')
router.get('/:id', auth, async(req, res, next) => {
try {
let id = req.params.id
let pollQuestion = await PollQuestion.findById(id, {
let pollQuestion = await PollQuestion.findByPk(id, {
include: [
{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } },
{ model: PollAnswer, include: [PollVote] }
@ -61,7 +61,7 @@ router.all('*', auth, (req, res, next) => {
router.post('/', auth, async(req, res, next) => {
try {
let threadId = req.body.threadId
let thread = await Thread.findById(req.body.threadId)
let thread = await Thread.findByPk(req.body.threadId)
if(!thread) {
throw Errors.sequelizeValidation(Sequelize, {
error: 'You tried voting on a poll on a post that didn\'t exist?',
@ -129,7 +129,7 @@ router.post('/:id', auth, async(req, res, next) => {
value: req.params.id
})
let poll = await PollQuestion.findById(req.params.id, {
let poll = await PollQuestion.findByPk(req.params.id, {
include: [PollAnswer]
})
if(!poll) throw Errors.sequelizeValidation(Sequelize, {

View File

@ -19,7 +19,7 @@ const likeLimiter = rateLimit({
router.get('/:post_id', async(req, res, next) => {
try {
let post = await Post.findById(req.params.post_id, { include: Post.includeOptions() })
let post = await Post.findByPk(req.params.post_id, { include: Post.includeOptions() })
if(!post) throw Errors.sequelizeValidation(Sequelize, {
error: 'post does not exist',
path: 'id'
@ -43,7 +43,7 @@ router.all('*', auth, (req, res, next) => {
router.put('/:post_id/like', likeLimiter, auth, async(req, res, next) => {
try {
let post = await Post.findById(req.params.post_id)
let post = await Post.findByPk(req.params.post_id)
let user = await User.findOne({ where: { username: req.userData.username }})
if(!post) throw Errors.invalidParameter('id', 'post does not exist')
@ -58,7 +58,7 @@ router.put('/:post_id/like', likeLimiter, auth, async(req, res, next) => {
router.delete('/:post_id/like', likeLimiter, auth, async(req, res, next) => {
try {
let post = await Post.findById(req.params.post_id)
let post = await Post.findByPk(req.params.post_id)
let user = await User.findOne({ where: { username: req.userData.username }})
if(!post) throw Errors.invalidParameter('id', 'post does not exist')
@ -79,7 +79,7 @@ router.post('/', postLimiter, auth, async(req, res, next) => {
let user = await User.findOne(queryObj)
try {
//Will throw an error if banned
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
if(req.body.mentions) {
uniqueMentions = Notification.filterMentions(req.body.mentions)
@ -179,7 +179,7 @@ router.delete('/:post_id', auth, async(req, res, next) => {
res.status(401)
res.json({errors: [Errors.requestNotAuthorized]})
}
let post = await Post.findById(req.params.post_id)
let post = await Post.findByPk(req.params.post_id)
if(!post) throw Errors.sequelizeValidation(Sequelize, {
error: 'post does not exist',
path: 'id'

View File

@ -17,7 +17,7 @@ router.all('*', auth, (req, res, next) => {
})
router.post('/post', auth, async(req, res, next) => {
try {
let post = await Post.findById(req.body.postId)
let post = await Post.findByPk(req.body.postId)
if(!post) throw Report.InvalidPostId(req.body.postId)
@ -37,7 +37,7 @@ router.post('/post', auth, async(req, res, next) => {
router.post('/user', auth, async(req, res, next) => {
try {
let reportedUser = await Post.findById(req.body.userId)
let reportedUser = await Post.findByPk(req.body.userId)
if(!reportedUser) throw Report.InvalidUserId(req.body.userId)
@ -84,7 +84,7 @@ router.get('/', auth, async(req, res, next) => {
})
router.delete('/:id', auth, async(req, res, next) => {
try {
let report = await Report.findById(req.params.id)
let report = await Report.findByPk(req.params.id)
if(!report) throw Report.InvalidPostId(req.params.id)
await report.destroy()

View File

@ -1,3 +1,5 @@
const { Op } = require("sequelize");
let express = require('express')
let router = express.Router()
const auth = require('../lib/auth')
@ -38,7 +40,7 @@ router.get('/thread', async(req, res, next) => {
let threadTitles = await Thread.findAll({
where: {
name: { $like: '%' + searchString + '%' },
name: { [Op.like]: '%' + searchString + '%' },
id: offset
},
order: [ ['id', 'DESC'] ],
@ -67,7 +69,7 @@ router.get('/thread', async(req, res, next) => {
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }],
where: {
postNumber: 0,
plainText: { $like: '%' + searchString + '%' }
plainText: { [Op.like]: '%' + searchString + '%' }
}
},
{ model: Category },
@ -110,7 +112,7 @@ router.get('/thread', async(req, res, next) => {
let latestPosts = await Post.findAll({
where: {
$or: whereClause
[Op.or]: whereClause
},
order: [ ['ThreadId', 'DESC'] ],
include: [{ model: User, attributes: { exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset'] } }]
@ -142,7 +144,7 @@ router.get('/user', async(req, res, next) => {
let limit = 10
let users = await User.findAll({
where: {
username: { $like: '%' + searchString + '%' }
username: { [Op.like]: '%' + searchString + '%' }
},
order: [ ['username', 'DESC'] ],
attributes: {exclude: ['hash', 'email', 'emailVerified', 'koins', 'currency2', 'emailToken', 'passwordResetExpiry', 'passwordResetToken', 'experimentMode', 'developerMode', 'cookieOptOut', 'deleteCode', 'jwtOffset']},
@ -166,7 +168,7 @@ router.get('/team', async(req, res, next) => {
let limit = 10
let teams = await Team.findAll({
where: {
username: { $like: '%' + searchString + '%' }
username: { [Op.like]: '%' + searchString + '%' }
},
order: [ ['username', 'DESC'] ],
attributes: {exclude: ['banReason']},

View File

@ -155,8 +155,7 @@ router.get('/view/:username', async(req, res, next) => {
if (user.userWallOptOut) {
throw Errors.userWallOptOut
}
let meta = await user.getMeta(limit)
res.json(Object.assign(user.toJSON(limit), {meta}))
res.json(Object.assign(user.toJSON(limit)))
} else {
let team = await Team.findOne(queryObj)
if (!team) throw Errors.accountDoesNotExist
@ -397,7 +396,7 @@ router.get('/', async(req, res, next) => {
router.put('/join/:username', auth, async(req, res, next) => {
try {
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
let team = await Team.findOne({
where: { username: req.params.username }
})
@ -468,7 +467,7 @@ router.get('/check/:username', auth, async(req, res, next) => {
router.put('/leave/:username', auth, async(req, res, next) => {
try {
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
let team = await Team.findOne({
where: { username: req.params.username }
})
@ -523,7 +522,7 @@ router.get('/invite/:username', async(req, res, next) => {
router.post('/invite/:code', auth, async(req, res, next) => {
try {
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
let code = await TeamInvite.findOne({
where: {code: req.params.code}
})

View File

@ -101,7 +101,7 @@ router.put('/modify/:username', auth, async(req, res, next) => {
if(!req.userData.username) {
throw Errors.requestNotAuthorized
}
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
let user1 = await Team.findOne({ where: {
username: req.params.username
}})

View File

@ -59,7 +59,7 @@ router.post('/post', postLimiter, auth, async(req, res, next) => {
let getWallUser = await Team.findOne(teamToId)
try {
//Will throw an error if banned
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
if(getWallUser.banned) {
throw Errors.teamBanned
@ -129,7 +129,7 @@ router.delete('/:post_id', auth, async(req, res, next) => {
res.status(401)
res.json({errors: [Errors.requestNotAuthorized]})
}
let post = await userWall.findById(req.params.post_id)
let post = await userWall.findByPk(req.params.post_id)
if(!post) throw Errors.sequelizeValidation(Sequelize, {
error: 'post does not exist',
path: 'id'
@ -141,4 +141,4 @@ router.delete('/:post_id', auth, async(req, res, next) => {
} catch (e) { next(e) }
})
module.exports = router
module.exports = router

View File

@ -14,7 +14,7 @@ const postLimiter = rateLimit({
router.get('/:thread_id', async(req, res, next) => {
try {
let { from, limit } = pagination.getPaginationProps(req.query)
let thread = await Thread.findById(req.params.thread_id, {
let thread = await Thread.findByPk(req.params.thread_id, {
include: Thread.includeOptions(from, limit)
})
if(!thread) throw Errors.invalidParameter('id', 'thread does not exist')
@ -42,7 +42,7 @@ router.post('/', postLimiter, auth, async(req, res, next) => {
let validationErrors = []
try {
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
let category = await Category.findOne({ where: {
value: req.body.category
@ -101,7 +101,7 @@ router.all('*', auth, async(req, res, next) => {
router.delete('/:thread_id', auth, async(req, res, next) => {
try {
let thread = await Thread.findById(req.params.thread_id)
let thread = await Thread.findByPk(req.params.thread_id)
if(!thread) {
throw Errors.sequelizeValidation(Sequelize, {
@ -135,7 +135,7 @@ router.delete('/:thread_id', auth, async(req, res, next) => {
router.put('/:thread_id', auth, async(req, res, next) => {
try {
let thread = await Thread.findById(req.params.thread_id)
let thread = await Thread.findByPk(req.params.thread_id)
if(!thread) {
res.status(400)

View File

@ -187,9 +187,7 @@ router.get('/:username', async(req, res, next) => {
throw Errors.userWallOptOut
}
let meta = await user.getMeta(limit)
res.json(Object.assign(user.toJSON(limit), {meta}))
res.json(Object.assign(user.toJSON(limit)))
} else if (req.query.threads) {
let queryString = ''

View File

@ -59,7 +59,7 @@ router.post('/post', postLimiter, auth, async(req, res, next) => {
let getWallUser = await User.findOne(usernameToUserId)
try {
//Will throw an error if banned
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
if (req.body.mentions) {
uniqueMentions = Notification.filterMentions(req.body.mentions)
@ -125,7 +125,7 @@ router.delete('/:post_id', auth, async(req, res, next) => {
res.status(401)
res.json({errors: [Errors.requestNotAuthorized]})
}
let post = await userWall.findById(req.params.post_id)
let post = await userWall.findByPk(req.params.post_id)
if(!post) throw Errors.sequelizeValidation(Sequelize, {
error: 'post does not exist',
path: 'id'

View File

@ -608,7 +608,7 @@ router.put('/preferences', auth, async(req, res, next) => {
if(!req.userData.username) {
throw Errors.requestNotAuthorized
}
await Ban.ReadOnlyMode(req.userData.username)
await Ban.ReadOnlyMode(req.userData.UserId)
if(req.autosan.body.description !== undefined) {
let user = await User.update({ description: req.autosan.body.description }, { where: {

127
yarn.lock
View File

@ -73,16 +73,6 @@
resolved "https://npm.open-registry.dev/@types/cookiejar/-/cookiejar-2.1.1.tgz#90b68446364baf9efd8e8349bb36bd3852b75b80"
integrity sha512-aRnpPa7ysx3aNW60hTiCtLHlQaIFsXFCgQlpakNgDNVFzbtusSY8PwjAQgRWfSk0ekNoBjO51eQRB6upA9uuyw==
"@types/geojson@^1.0.0":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-1.0.6.tgz#3e02972728c69248c2af08d60a48cbb8680fffdf"
integrity sha512-Xqg/lIZMrUd0VRmSRbCAewtwGZiAk3mEUDvV4op1tGl+LvyPcb/MIOSxTl9z+9+J+R4/vpjiCAT4xeKzH9ji1w==
"@types/geojson@^7946.0.0 || ^1.0.0":
version "7946.0.7"
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.7.tgz#c8fa532b60a0042219cdf173ca21a975ef0666ad"
integrity sha512-wE2v81i4C4Ol09RtsWFAqg3BUitWbHSpSlIo+bNdsCJijO9sjme+zm+73ZMCa/qMC8UEERxzGbvmr1cffo2SiQ==
"@types/node@*":
version "13.13.4"
resolved "https://npm.open-registry.dev/@types/node/-/node-13.13.4.tgz#1581d6c16e3d4803eb079c87d4ac893ee7501c2c"
@ -460,7 +450,7 @@ bluebird@3.5.0:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c"
integrity sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=
bluebird@^3.3.4, bluebird@^3.4.6, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.3, bluebird@^3.7.2:
bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.3, bluebird@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
@ -1079,7 +1069,7 @@ date-format@^3.0.0:
resolved "https://registry.yarnpkg.com/date-format/-/date-format-3.0.0.tgz#eb8780365c7d2b1511078fb491e6479780f3ad95"
integrity sha512-eyTcpKOcamdhWJXj56DpQMo1ylSQpcGtGKXcU0Tb97+K56/CF5amAqqqNj0+KvA0iw2ynxtHWFsPDSClCxe48w==
debug@2, debug@2.6.9, debug@^2.2.0, debug@^2.6.9:
debug@2, debug@2.6.9, debug@^2.2.0:
version "2.6.9"
resolved "https://npm.open-registry.dev/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
@ -1208,7 +1198,7 @@ depd@2.0.0, depd@~2.0.0:
resolved "https://npm.open-registry.dev/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
depd@^1.1.0, depd@~1.1.2:
depd@~1.1.2:
version "1.1.2"
resolved "https://npm.open-registry.dev/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=
@ -1358,11 +1348,6 @@ dotenv@^4.0.0:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
integrity sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=
dottie@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/dottie/-/dottie-1.1.1.tgz#45c2a3f48bd6528eeed267a69a848eaaca6faa6a"
integrity sha1-RcKj9IvWUo7u0memmoSOqspvqmo=
dottie@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/dottie/-/dottie-2.0.2.tgz#cc91c0726ce3a054ebf11c55fbc92a7f266dd154"
@ -1930,11 +1915,6 @@ generate-function@^2.3.1:
dependencies:
is-property "^1.0.2"
generic-pool@2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-2.4.2.tgz#886bc5bf0beb7db96e81bcbba078818de5a62683"
integrity sha1-iGvFvwvrfblugby7oHiBjeWmJoM=
get-caller-file@^1.0.1:
version "1.0.3"
resolved "https://npm.open-registry.dev/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
@ -2270,7 +2250,7 @@ indexof@0.0.1:
resolved "https://npm.open-registry.dev/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d"
integrity sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=
inflection@1.12.0, inflection@^1.6.0, inflection@~1.12.0:
inflection@1.12.0, inflection@~1.12.0:
version "1.12.0"
resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.12.0.tgz#a200935656d6f5f6bc4dc7502e1aecb703228416"
integrity sha1-ogCTVlbW9fa8TcdQLhrstwMihBY=
@ -2850,7 +2830,7 @@ lodash.unescape@^4.0.1:
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=
lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.5, lodash@~4.17.4:
lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.5, lodash@~4.17.4:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
@ -3098,14 +3078,14 @@ mocha@^5.2.0:
mkdirp "0.5.1"
supports-color "5.4.0"
moment-timezone@^0.5.21, moment-timezone@^0.5.4:
moment-timezone@^0.5.21:
version "0.5.31"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.31.tgz#9c40d8c5026f0c7ab46eda3d63e49c155148de05"
integrity sha512-+GgHNg8xRhMXfEbv81iDtrVeTcWt0kWmTEY1XQK14dICTXnWJnT0dxdlPspwqF3keKMVPXwayEsk1DI0AA/jdA==
dependencies:
moment ">= 2.9.0"
moment@2.x.x, "moment@>= 2.9.0", moment@^2.13.0, moment@^2.24.0:
moment@2.x.x, "moment@>= 2.9.0", moment@^2.24.0:
version "2.27.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d"
integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==
@ -4128,15 +4108,7 @@ resolve@^1.10.0, resolve@^1.5.0:
dependencies:
path-parse "^1.0.6"
retry-as-promised@^2.0.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/retry-as-promised/-/retry-as-promised-2.3.2.tgz#cd974ee4fd9b5fe03cbf31871ee48221c07737b7"
integrity sha1-zZdO5P2bX+A8vzGHHuSCIcB3N7c=
dependencies:
bluebird "^3.4.6"
debug "^2.6.9"
retry-as-promised@^3.1.0:
retry-as-promised@^3.1.0, retry-as-promised@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/retry-as-promised/-/retry-as-promised-3.2.0.tgz#769f63d536bec4783549db0777cb56dadd9d8543"
integrity sha512-CybGs60B7oYU/qSQ6kuaFmRd9sTZ6oXSc0toqePvV74Ac6/IFZSI1ReFQmtCN+uvW1Mtqdwpvt/LGOiCBAY2Mg==
@ -4180,11 +4152,16 @@ saxes@^5.0.0:
dependencies:
xmlchars "^2.2.0"
"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
semver@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
semver@^7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
@ -4256,27 +4233,31 @@ sequelize-pool@^1.0.2:
dependencies:
bluebird "^3.5.3"
sequelize@3.35.1:
version "3.35.1"
resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-3.35.1.tgz#1f4fc124090fec87dba98c6ceae15735f7b8f0db"
integrity sha512-NhUmk4U+fS33/XW8CZsu1fSk8iSseJWF8fKuSa+kDIAK+lmA254QBbDAJiFvdH0P1ZSxyIS1zXl8FqVK5JDq9g==
sequelize-pool@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/sequelize-pool/-/sequelize-pool-2.3.0.tgz#64f1fe8744228172c474f530604b6133be64993d"
integrity sha512-Ibz08vnXvkZ8LJTiUOxRcj1Ckdn7qafNZ2t59jYHMX1VIebTAOYefWdRYFt6z6+hy52WGthAHAoLc9hvk3onqA==
sequelize@5.22.3:
version "5.22.3"
resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-5.22.3.tgz#7e7a92ddd355d883c9eb11cdb106d874d0d2636f"
integrity sha512-+nxf4TzdrB+PRmoWhR05TP9ukLAurK7qtKcIFv5Vhxm5Z9v+d2PcTT6Ea3YAoIQVkZ47QlT9XWAIUevMT/3l8Q==
dependencies:
bluebird "^3.3.4"
depd "^1.1.0"
dottie "^1.0.0"
generic-pool "2.4.2"
inflection "^1.6.0"
lodash "^4.17.10"
moment "^2.13.0"
moment-timezone "^0.5.4"
retry-as-promised "^2.0.0"
semver "^5.0.1"
shimmer "1.1.0"
terraformer-wkt-parser "^1.1.0"
bluebird "^3.5.0"
cls-bluebird "^2.1.0"
debug "^4.1.1"
dottie "^2.0.0"
inflection "1.12.0"
lodash "^4.17.15"
moment "^2.24.0"
moment-timezone "^0.5.21"
retry-as-promised "^3.2.0"
semver "^6.3.0"
sequelize-pool "^2.3.0"
toposort-class "^1.0.1"
uuid "^3.0.0"
validator "^5.2.0"
wkx "0.2.0"
uuid "^3.3.3"
validator "^10.11.0"
wkx "^0.4.8"
sequelize@~5.6.1:
version "5.6.1"
@ -4351,11 +4332,6 @@ shebang-regex@^1.0.0:
resolved "https://npm.open-registry.dev/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
shimmer@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/shimmer/-/shimmer-1.1.0.tgz#97d7377137ffbbab425522e429fe0aa89a488b35"
integrity sha1-l9c3cTf/u6tCVSLkKf4KqJpIizU=
shimmer@^1.1.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/shimmer/-/shimmer-1.2.1.tgz#610859f7de327b587efebf501fb43117f9aff337"
@ -4845,21 +4821,6 @@ tar-stream@^2.0.0:
inherits "^2.0.3"
readable-stream "^3.1.1"
terraformer-wkt-parser@^1.1.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/terraformer-wkt-parser/-/terraformer-wkt-parser-1.2.1.tgz#8041e2aeb0c9f2b4cbbec8ec2c5c00c45ddfee02"
integrity sha512-+CJyNLWb3lJ9RsZMTM66BY0MT3yIo4l4l22Jd9CrZuwzk54fsu4Sc7zejuS9fCITTuTQy3p06d4MZMVI7v5wSg==
dependencies:
"@types/geojson" "^1.0.0"
terraformer "~1.0.5"
terraformer@~1.0.5:
version "1.0.12"
resolved "https://registry.yarnpkg.com/terraformer/-/terraformer-1.0.12.tgz#39e08f9c753606421acce02e122440c72dfa12d3"
integrity sha512-MokUp0+MFal4CmJDVL6VAO1bKegeXcBM2RnPVfqcFIp2IIv8EbPAjG0j/vEy/vuKB8NVMMSF2vfpVS/QLe4DBg==
optionalDependencies:
"@types/geojson" "^7946.0.0 || ^1.0.0"
thunkify@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/thunkify/-/thunkify-2.1.2.tgz#faa0e9d230c51acc95ca13a361ac05ca7e04553d"
@ -5077,7 +5038,7 @@ uue@^3.1.0:
escape-string-regexp "~1.0.5"
extend "~3.0.0"
uuid@^3.0.0, uuid@^3.2.1, uuid@^3.3.2:
uuid@^3.2.1, uuid@^3.3.2, uuid@^3.3.3:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
@ -5105,11 +5066,6 @@ validator@^12.0.0:
resolved "https://registry.yarnpkg.com/validator/-/validator-12.2.0.tgz#660d47e96267033fd070096c3b1a6f2db4380a0a"
integrity sha512-jJfE/DW6tIK1Ek8nCfNFqt8Wb3nzMoAbocBF6/Icgg1ZFSBpObdnwVY2jQj6qUqzhx5jc71fpvBWyLGO7Xl+nQ==
validator@^5.2.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/validator/-/validator-5.7.0.tgz#7a87a58146b695ac486071141c0c49d67da05e5c"
integrity sha1-eoelgUa2laxIYHEUHAxJ1n2gXlw=
vary@~1.1.2:
version "1.1.2"
resolved "https://npm.open-registry.dev/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
@ -5213,12 +5169,7 @@ with-callback@^1.0.2:
resolved "https://registry.yarnpkg.com/with-callback/-/with-callback-1.0.2.tgz#a09629b9a920028d721404fb435bdcff5c91bc21"
integrity sha1-oJYpuakgAo1yFAT7Q1vc/1yRvCE=
wkx@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/wkx/-/wkx-0.2.0.tgz#76c24f16acd0cd8f93cd34aa331e0f7961256e84"
integrity sha1-dsJPFqzQzY+TzTSqMx4PeWElboQ=
wkx@^0.4.6:
wkx@^0.4.6, wkx@^0.4.8:
version "0.4.8"
resolved "https://registry.yarnpkg.com/wkx/-/wkx-0.4.8.tgz#a092cf088d112683fdc7182fd31493b2c5820003"
integrity sha512-ikPXMM9IR/gy/LwiOSqWlSL3X/J5uk9EO2hHNRXS41eTLXaUFEVw9fn/593jW/tE5tedNg8YjT5HkCa4FqQZyQ==