(sourceId: string, sessions: Array<{ name: string; remoteSessionId: string }>)
| 142 | // ==================== ImportSession CRUD ==================== |
| 143 | |
| 144 | addSessions(sourceId: string, sessions: Array<{ name: string; remoteSessionId: string }>): ImportSession[] { |
| 145 | const sources = this.loadAll() |
| 146 | const ds = sources.find((s) => s.id === sourceId) |
| 147 | if (!ds) return [] |
| 148 | |
| 149 | const added: ImportSession[] = [] |
| 150 | for (const sess of sessions) { |
| 151 | if (ds.sessions.some((s) => s.remoteSessionId === sess.remoteSessionId)) continue |
| 152 | const imp: ImportSession = { |
| 153 | id: generateId('sess'), |
| 154 | name: sess.name, |
| 155 | remoteSessionId: sess.remoteSessionId, |
| 156 | targetSessionId: '', |
| 157 | lastPullAt: 0, |
| 158 | lastStatus: 'idle', |
| 159 | lastError: '', |
| 160 | lastNewMessages: 0, |
| 161 | } |
| 162 | ds.sessions.push(imp) |
| 163 | added.push(imp) |
| 164 | } |
| 165 | this.saveAll(sources) |
| 166 | return added |
| 167 | } |
| 168 | |
| 169 | removeSession(sourceId: string, sessionId: string): ImportSession | null { |
| 170 | const sources = this.loadAll() |
no test coverage detected