-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a096c0
commit 7d806fa
Showing
12 changed files
with
590 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Model, { column, table, validate, type } from './Model' | ||
|
||
/** | ||
* Model class for user sessions | ||
*/ | ||
@table({ | ||
indexes: [{ | ||
fields: ['deviceToken', 'userId'], | ||
}], | ||
}) | ||
export default class ApplePushSubscription extends Model { | ||
@validate({ isUUID: 4 }) | ||
@column(type.UUID, { primaryKey: true }) | ||
static id = type.UUIDV4 | ||
|
||
@column(type.STRING, { unique: true }) | ||
static deviceToken = undefined | ||
|
||
@validate({ isUUID: 4 }) | ||
@column(type.UUID) | ||
static userId = undefined | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
static getScopes (models) { | ||
return { | ||
defaultScope: [{ | ||
include: [ | ||
{ | ||
model: models.User, | ||
as: 'user', | ||
required: true, | ||
}, | ||
], | ||
}, { | ||
override: true, | ||
}], | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
static associate (models) { | ||
super.associate(models) | ||
models.ApplePushSubscription.belongsTo(models.User, { as: 'user' }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import Model, { column, table, validate, type } from './Model' | ||
|
||
/** | ||
* Model class for user sessions | ||
*/ | ||
@table({ | ||
indexes: [{ | ||
fields: ['endpoint', 'userId'], | ||
}], | ||
}) | ||
export default class WebPushSubscription extends Model { | ||
@validate({ isUUID: 4 }) | ||
@column(type.UUID, { primaryKey: true }) | ||
static id = type.UUIDV4 | ||
|
||
@column(type.STRING, { unique: true }) | ||
static endpoint = undefined | ||
|
||
@column(type.INTEGER, { allowNull: true }) | ||
static expirationTime = undefined | ||
|
||
@column(type.STRING) | ||
static auth = undefined | ||
|
||
@column(type.STRING) | ||
static p256dh = undefined | ||
|
||
@column(type.BOOLEAN) | ||
static alertsOnly = true | ||
|
||
@column(type.BOOLEAN) | ||
static pc = true | ||
|
||
@column(type.BOOLEAN) | ||
static xb = true | ||
|
||
@column(type.BOOLEAN) | ||
static ps = true | ||
|
||
@validate({ isUUID: 4 }) | ||
@column(type.UUID) | ||
static userId = undefined | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
static getScopes (models) { | ||
return { | ||
defaultScope: [{ | ||
include: [ | ||
{ | ||
model: models.User, | ||
as: 'user', | ||
required: true, | ||
}, | ||
], | ||
}, { | ||
override: true, | ||
}], | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
static associate (models) { | ||
super.associate(models) | ||
models.WebPushSubscription.belongsTo(models.User, { as: 'user' }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.