(
userIdentifier: string,
identifierType: "slack_id" | "email" | "anonymous"
)
| 259 | } |
| 260 | |
| 261 | async getSessionsByUser( |
| 262 | userIdentifier: string, |
| 263 | identifierType: "slack_id" | "email" | "anonymous" |
| 264 | ): Promise<SiSession[]> { |
| 265 | let column: string; |
| 266 | switch (identifierType) { |
| 267 | case "slack_id": |
| 268 | column = "user_slack_id"; |
| 269 | break; |
| 270 | case "email": |
| 271 | column = "user_email"; |
| 272 | break; |
| 273 | case "anonymous": |
| 274 | column = "user_anonymous_id"; |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | const result = await query( |
| 279 | `SELECT * FROM si_sessions WHERE ${column} = $1 ORDER BY created_at DESC`, |
| 280 | [userIdentifier] |
| 281 | ); |
| 282 | |
| 283 | return result.rows.map((row) => this.deserializeSession(row)); |
| 284 | } |
| 285 | |
| 286 | // -------------------------------------------------------------------------- |
| 287 | // Messages |
no test coverage detected