use sharedInbox to send events, fix #19
This commit is contained in:
@@ -118,7 +118,8 @@ const userController = {
|
||||
// send response to client
|
||||
res.json(event)
|
||||
|
||||
if (req.user) { federation.sendEvent(event, req.user) }
|
||||
const user = await User.findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' }})
|
||||
if (user) { federation.sendEvent(event, user) }
|
||||
|
||||
// res.sendStatus(200)
|
||||
|
||||
@@ -209,7 +210,7 @@ const userController = {
|
||||
|
||||
async current (req, res) {
|
||||
if (!req.user) return res.status(400).send('Not logged')
|
||||
const user = await User.findByPk(req.user.id, { include: [ FedUsers ]})
|
||||
const user = await User.findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' } })
|
||||
res.json(user)
|
||||
},
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
user.associate = function (models) {
|
||||
// associations can be defined here
|
||||
user.hasMany(models.event)
|
||||
user.belongsToMany(models.fed_users, { through: 'user_followers' })
|
||||
user.belongsToMany(models.fed_users, { through: 'user_followers', as: 'followers' })
|
||||
}
|
||||
|
||||
user.prototype.comparePassword = async function (pwd) {
|
||||
|
||||
Reference in New Issue
Block a user