podverse-orm 5.1.21-alpha.0 → 5.1.24-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,7 +29,7 @@ __decorate([
|
|
|
29
29
|
__metadata("design:type", Object)
|
|
30
30
|
], AccountUPDevice.prototype, "up_auth_key", void 0);
|
|
31
31
|
__decorate([
|
|
32
|
-
(0, typeorm_1.Column)(),
|
|
32
|
+
(0, typeorm_1.Column)({ unique: true }),
|
|
33
33
|
__metadata("design:type", Number)
|
|
34
34
|
], AccountUPDevice.prototype, "account_id", void 0);
|
|
35
35
|
__decorate([
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateAccountUPDeviceParams, UpdateAccountUPDeviceParams
|
|
1
|
+
import { CreateAccountUPDeviceParams, UpdateAccountUPDeviceParams } from 'podverse-helpers';
|
|
2
2
|
import { AccountUPDevice } from '@orm/entities/account/accountUPDevice';
|
|
3
3
|
import { BaseManyService } from '@orm/services/base/baseManyService';
|
|
4
4
|
export declare class AccountUPDeviceService extends BaseManyService<AccountUPDevice, 'account'> {
|
|
@@ -7,13 +7,13 @@ export declare class AccountUPDeviceService extends BaseManyService<AccountUPDev
|
|
|
7
7
|
constructor();
|
|
8
8
|
create(account_id: number, params: CreateAccountUPDeviceParams): Promise<AccountUPDevice>;
|
|
9
9
|
update(account_id: number, params: UpdateAccountUPDeviceParams): Promise<AccountUPDevice>;
|
|
10
|
-
delete(account_id: number
|
|
10
|
+
delete(account_id: number): Promise<void>;
|
|
11
11
|
getUPSubscriptionsByChannelIdText(channel_id_text: string): Promise<Array<{
|
|
12
12
|
up_endpoint: string;
|
|
13
13
|
up_auth_key: string | null;
|
|
14
14
|
locale: string;
|
|
15
15
|
}>>;
|
|
16
|
-
|
|
16
|
+
getForAccount(account_id: number): Promise<AccountUPDevice | null>;
|
|
17
17
|
getAllForAccountIds(account_ids: number[]): Promise<AccountUPDevice[]>;
|
|
18
18
|
updateLocaleForAccount(account_id: number, params: {
|
|
19
19
|
locale: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountUPDevice.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountUPDevice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,
|
|
1
|
+
{"version":3,"file":"accountUPDevice.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountUPDevice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,EAA+B,MAAM,kBAAkB,CAAC;AAEzH,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAKrE,qBAAa,sBAAuB,SAAQ,eAAe,CAAC,eAAe,EAAE,SAAS,CAAC;IACrF,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,iCAAiC,CAAoC;;IAQvE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,eAAe,CAAC;IAuBzF,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,eAAe,CAAC;IAqBrB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASzC,iCAAiC,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9E,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IAmBG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAIlE,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAKtE,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAerF,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAY7D"}
|
|
@@ -31,8 +31,17 @@ class AccountUPDeviceService extends baseManyService_1.BaseManyService {
|
|
|
31
31
|
}
|
|
32
32
|
const { up_endpoint, up_auth_key } = params;
|
|
33
33
|
const locale = ((_b = (_a = account.account_settings) === null || _a === void 0 ? void 0 : _a.account_settings_locale) === null || _b === void 0 ? void 0 : _b.locale) || config_1.config.defaults.account.settings.locale;
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const existing = yield this.repositoryRead.findOne({ where: { account_id } });
|
|
35
|
+
if (existing) {
|
|
36
|
+
yield this.repositoryReadWrite.remove(existing);
|
|
37
|
+
}
|
|
38
|
+
const newDevice = this.repositoryReadWrite.create({
|
|
39
|
+
account_id,
|
|
40
|
+
up_endpoint,
|
|
41
|
+
up_auth_key,
|
|
42
|
+
locale
|
|
43
|
+
});
|
|
44
|
+
return this.repositoryReadWrite.save(newDevice);
|
|
36
45
|
});
|
|
37
46
|
}
|
|
38
47
|
update(account_id, params) {
|
|
@@ -44,27 +53,24 @@ class AccountUPDeviceService extends baseManyService_1.BaseManyService {
|
|
|
44
53
|
}
|
|
45
54
|
const { up_endpoint, up_auth_key } = params;
|
|
46
55
|
const locale = ((_b = (_a = account.account_settings) === null || _a === void 0 ? void 0 : _a.account_settings_locale) === null || _b === void 0 ? void 0 : _b.locale) || config_1.config.defaults.account.settings.locale;
|
|
47
|
-
//
|
|
48
|
-
const existing = yield this.repositoryRead.findOne({ where: { account_id
|
|
56
|
+
// Since there's only one device per account, find by account_id
|
|
57
|
+
const existing = yield this.repositoryRead.findOne({ where: { account_id } });
|
|
49
58
|
if (existing) {
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
existing.up_endpoint = up_endpoint;
|
|
60
|
+
existing.up_auth_key = up_auth_key;
|
|
61
|
+
existing.locale = locale;
|
|
62
|
+
return this.repositoryReadWrite.save(existing);
|
|
52
63
|
}
|
|
53
64
|
throw new Error('UP Device not found for update.');
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
|
-
delete(account_id
|
|
67
|
+
delete(account_id) {
|
|
57
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
69
|
const account = yield this.accountService.get(account_id);
|
|
59
70
|
if (!account) {
|
|
60
71
|
throw new Error('Account not found.');
|
|
61
72
|
}
|
|
62
|
-
|
|
63
|
-
const existing = yield this.repositoryRead.findOne({ where: { account_id, up_endpoint } });
|
|
64
|
-
if (existing) {
|
|
65
|
-
return this._delete(account, { up_endpoint });
|
|
66
|
-
}
|
|
67
|
-
throw new Error('UP Device not found for deletion.');
|
|
73
|
+
yield this.repositoryReadWrite.delete({ account_id });
|
|
68
74
|
});
|
|
69
75
|
}
|
|
70
76
|
getUPSubscriptionsByChannelIdText(channel_id_text) {
|
|
@@ -72,8 +78,9 @@ class AccountUPDeviceService extends baseManyService_1.BaseManyService {
|
|
|
72
78
|
const notificationChannels = yield this.accountNotificationChannelService.getAllByChannelIdText(channel_id_text);
|
|
73
79
|
const subscriptions = [];
|
|
74
80
|
for (const notificationChannel of notificationChannels) {
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
// Since there's only one device per account, use findOne
|
|
82
|
+
const device = yield this.repositoryRead.findOne({ where: { account_id: notificationChannel.account_id } });
|
|
83
|
+
if (device) {
|
|
77
84
|
subscriptions.push({
|
|
78
85
|
up_endpoint: device.up_endpoint,
|
|
79
86
|
up_auth_key: device.up_auth_key,
|
|
@@ -84,9 +91,9 @@ class AccountUPDeviceService extends baseManyService_1.BaseManyService {
|
|
|
84
91
|
return subscriptions;
|
|
85
92
|
});
|
|
86
93
|
}
|
|
87
|
-
|
|
94
|
+
getForAccount(account_id) {
|
|
88
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
return this.repositoryRead.
|
|
96
|
+
return this.repositoryRead.findOne({ where: { account_id } });
|
|
90
97
|
});
|
|
91
98
|
}
|
|
92
99
|
getAllForAccountIds(account_ids) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-orm",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.24-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"module-alias": "^2.2.3",
|
|
22
22
|
"nanoid": "^5.1.6",
|
|
23
23
|
"pg": "^8.16.3",
|
|
24
|
-
"podverse-helpers": "^5.1.
|
|
24
|
+
"podverse-helpers": "^5.1.24-alpha.0",
|
|
25
25
|
"typeorm": "^0.3.26",
|
|
26
26
|
"typeorm-naming-strategies": "^4.1.0"
|
|
27
27
|
},
|