@@ -16,7 +16,16 @@ import { toJson, fromJson } from '../../utils.js';
1616 * @param {string } params.userId - Owner user id for inserts; preserved on updates.
1717 * @returns {void }
1818 */
19- export const upsertJob = ( { jobId, name, blacklist = [ ] , enabled = true , provider, notificationAdapter, userId } ) => {
19+ export const upsertJob = ( {
20+ jobId,
21+ name,
22+ blacklist = [ ] ,
23+ enabled = true ,
24+ provider,
25+ notificationAdapter,
26+ userId,
27+ shareWithUsers = [ ] ,
28+ } ) => {
2029 const id = jobId || nanoid ( ) ;
2130 const existing = SqliteConnection . query ( `SELECT id, user_id FROM jobs WHERE id = @id LIMIT 1` , { id } ) [ 0 ] ;
2231 const ownerId = existing ? existing . user_id : userId ;
@@ -27,28 +36,31 @@ export const upsertJob = ({ jobId, name, blacklist = [], enabled = true, provide
2736 name = @name,
2837 blacklist = @blacklist,
2938 provider = @provider,
30- notification_adapter = @notification_adapter
39+ notification_adapter = @notification_adapter,
40+ shared_with_user = @shareWithUsers
3141 WHERE id = @id` ,
3242 {
3343 id,
3444 enabled : enabled ? 1 : 0 ,
3545 name : name ?? null ,
3646 blacklist : toJson ( blacklist ?? [ ] ) ,
47+ shareWithUsers : toJson ( shareWithUsers ?? [ ] ) ,
3748 provider : toJson ( provider ?? [ ] ) ,
3849 notification_adapter : toJson ( notificationAdapter ?? [ ] ) ,
3950 } ,
4051 ) ;
4152 } else {
4253 SqliteConnection . execute (
43- `INSERT INTO jobs (id, user_id, enabled, name, blacklist, provider, notification_adapter)
44- VALUES (@id, @user_id, @enabled, @name, @blacklist, @provider, @notification_adapter)` ,
54+ `INSERT INTO jobs (id, user_id, enabled, name, blacklist, provider, notification_adapter, shared_with_user )
55+ VALUES (@id, @user_id, @enabled, @name, @blacklist, @provider, @notification_adapter, @shareWithUsers )` ,
4556 {
4657 id,
4758 user_id : ownerId ,
4859 enabled : enabled ? 1 : 0 ,
4960 name : name ?? null ,
5061 blacklist : toJson ( blacklist ?? [ ] ) ,
5162 provider : toJson ( provider ?? [ ] ) ,
63+ shareWithUsers : toJson ( shareWithUsers ?? [ ] ) ,
5264 notification_adapter : toJson ( notificationAdapter ?? [ ] ) ,
5365 } ,
5466 ) ;
@@ -129,6 +141,7 @@ export const getJobs = () => {
129141 j.name,
130142 j.blacklist,
131143 j.provider,
144+ j.shared_with_user,
132145 j.notification_adapter AS notificationAdapter,
133146 (SELECT COUNT(1) FROM listings l WHERE l.job_id = j.id) AS numberOfFoundListings
134147 FROM jobs j
@@ -139,6 +152,7 @@ export const getJobs = () => {
139152 enabled : ! ! row . enabled ,
140153 blacklist : fromJson ( row . blacklist , [ ] ) ,
141154 provider : fromJson ( row . provider , [ ] ) ,
155+ shared_with_user : fromJson ( row . shared_with_user , [ ] ) ,
142156 notificationAdapter : fromJson ( row . notificationAdapter , [ ] ) ,
143157 } ) ) ;
144158} ;
0 commit comments