@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.96 → 2.4.2-dev.98
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.
- package/package.json +1 -1
- package/src/FcmToken.js +33 -0
- package/src/Site.js +3 -1
package/package.json
CHANGED
package/src/FcmToken.js
CHANGED
|
@@ -70,4 +70,37 @@ export default class FcmToken extends FireModel {
|
|
|
70
70
|
"FCMトークンは更新できません。新しいトークンでドキュメントを作成してください。",
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 指定されたUIDに関連するすべてのFCMトークンドキュメントを削除します。
|
|
76
|
+
* - ドキュメントIDはトークンそのものなので、uidフィールドでクエリして削除します。
|
|
77
|
+
* - Firebase Authentication ユーザー削除時のクリーンアップ処理などで使用されます。
|
|
78
|
+
* @param {string} uid - ユーザーID(Firebase Authentication UID)
|
|
79
|
+
* @param {Object} [options] - オプション
|
|
80
|
+
* @param {import('firebase-admin/firestore').Firestore} [options.firestore] - Firestoreインスタンス(省略時は自動取得)
|
|
81
|
+
* @returns {Promise<number>} 削除されたドキュメントの数
|
|
82
|
+
* @throws {Error} uidが指定されていない場合
|
|
83
|
+
*/
|
|
84
|
+
static async deleteByUid(uid, options = {}) {
|
|
85
|
+
if (!uid) {
|
|
86
|
+
throw new Error("UIDが指定されていません。");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// FcmTokenインスタンスを生成
|
|
90
|
+
const instance = new this();
|
|
91
|
+
|
|
92
|
+
// fetchDocsでuidに該当するドキュメントのインスタンス配列を取得
|
|
93
|
+
const tokens = await instance.fetchDocs({
|
|
94
|
+
constraints: [["where", "uid", "==", uid]],
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (tokens.length === 0) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 各インスタンスのdeleteメソッドを使って削除
|
|
102
|
+
await Promise.all(tokens.map((token) => token.delete()));
|
|
103
|
+
|
|
104
|
+
return tokens.length;
|
|
105
|
+
}
|
|
73
106
|
}
|
package/src/Site.js
CHANGED
|
@@ -276,7 +276,9 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
276
276
|
configurable: true,
|
|
277
277
|
enumerable: true,
|
|
278
278
|
get() {
|
|
279
|
-
return
|
|
279
|
+
return (
|
|
280
|
+
!!this.constructionPeriodStartAt || !!this.constructionPeriodEndAt
|
|
281
|
+
);
|
|
280
282
|
},
|
|
281
283
|
set() {},
|
|
282
284
|
},
|