mirror of
https://github.com/usatiuk/photos.git
synced 2025-10-28 23:37:48 +01:00
workaround photos not loading bug
This commit is contained in:
1318
package-lock.json
generated
1318
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -79,15 +79,15 @@ export class Photo extends BaseEntity {
|
||||
public accessToken: string;
|
||||
|
||||
@Column({ type: "timestamp", default: null })
|
||||
public accessTokenExpiry: Date;
|
||||
public accessTokenExpiry: Date | null;
|
||||
|
||||
@Column({ type: "timestamp", default: null })
|
||||
@Column({ type: "timestamp", default: new Date(0) })
|
||||
public shotAt: Date;
|
||||
|
||||
@Column({ type: "timestamp", default: null })
|
||||
@Column({ type: "timestamp", default: new Date(0) })
|
||||
public createdAt: Date;
|
||||
|
||||
@Column({ type: "timestamp", default: null })
|
||||
@Column({ type: "timestamp", default: new Date(0) })
|
||||
public editedAt: Date;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.photos, {
|
||||
@@ -211,9 +211,9 @@ export class Photo extends BaseEntity {
|
||||
|
||||
public async getJWTToken(): Promise<string> {
|
||||
const now = new Date().getTime();
|
||||
const tokenExpiryOld = this.accessTokenExpiry.getTime();
|
||||
const tokenExpiryOld = this.accessTokenExpiry?.getTime();
|
||||
// If expires in more than 10 minutes then get from cache
|
||||
if (tokenExpiryOld - now - 60 * 10 * 1000 > 0) {
|
||||
if (tokenExpiryOld && tokenExpiryOld - now - 60 * 10 * 1000 > 0) {
|
||||
return this.accessToken;
|
||||
} else {
|
||||
const token = jwt.sign(await this.toJSON(), config.jwtSecret, {
|
||||
@@ -239,7 +239,10 @@ export class Photo extends BaseEntity {
|
||||
format: this.format,
|
||||
createdAt: this.createdAt.getTime(),
|
||||
editedAt: this.editedAt.getTime(),
|
||||
shotAt: this.shotAt.getTime(),
|
||||
// workaround weird bug where this.shotAt is null
|
||||
shotAt: this.shotAt
|
||||
? this.shotAt.getTime()
|
||||
: this.createdAt.getTime(),
|
||||
uploaded: this.uploaded,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { User } from "~entity/User";
|
||||
|
||||
export const devRouter = new Router();
|
||||
|
||||
devRouter.post("/dev/clean", async (ctx) => {
|
||||
devRouter.get("/dev/clean", async (ctx) => {
|
||||
await Photo.remove(await Photo.find());
|
||||
await User.remove(await User.find());
|
||||
ctx.body = { success: true };
|
||||
|
||||
Reference in New Issue
Block a user