diff --git a/CHANGELOG.md b/CHANGELOG.md index db4556f..e0cc684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ability for admins to delete posts - ability to upload file at `/upload` with the name profilePicture - publicPath to config file to configure the directory for public files +- profilePicture property to User model which is an url to the users profile picture ### Removed diff --git a/src/app.ts b/src/app.ts index 8036b3c..8c64094 100644 --- a/src/app.ts +++ b/src/app.ts @@ -21,6 +21,7 @@ import * as socketIoRedis from "socket.io-redis"; import {resolver} from "./graphql/resolvers"; import dataaccess from "./lib/dataAccess"; import globals from "./lib/globals"; +import {User} from "./lib/models"; import routes from "./routes"; const SequelizeStore = require("connect-session-sequelize")(session.Store); @@ -140,6 +141,9 @@ class App { .toFile(path.join(dir, req.session.userId + ".png")); success = true; fileName = `/data/profilePictures/${req.session.userId}.png`; + const user = await User.findByPk(req.session.userId); + user.profilePicture = fileName; + await user.save(); } else { res.status(400); } diff --git a/src/lib/models/User.ts b/src/lib/models/User.ts index 5901054..8db31e9 100644 --- a/src/lib/models/User.ts +++ b/src/lib/models/User.ts @@ -65,6 +65,9 @@ export class User extends Model { @Column({defaultValue: false, allowNull: false}) public isAdmin: boolean; + @Column({type: sqz.STRING(512)}) + public profilePicture: string; + @BelongsToMany(() => User, () => Friendship, "userId") public rFriends: User[];