Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
getraenkekasse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aaron Dötsch
getraenkekasse
Commits
ed47bfee
Commit
ed47bfee
authored
1 year ago
by
Aaron Dötsch
Browse files
Options
Downloads
Patches
Plain Diff
Increase type specitifity in notification handler
parent
f57464df
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/server/notifications/handler.ts
+4
-4
4 additions, 4 deletions
src/lib/server/notifications/handler.ts
with
4 additions
and
4 deletions
src/lib/server/notifications/handler.ts
+
4
−
4
View file @
ed47bfee
import
{
db
}
from
"
$lib/server/database
"
;
import
{
db
}
from
"
$lib/server/database
"
;
import
{
ChannelType
}
from
"
./channelTypes
"
;
import
{
ChannelType
}
from
"
./channelTypes
"
;
import
type
{
HandlerReturnType
,
NotificationChannel
,
NotificationData
,
NotificationType
,
PossibleNotificationType
}
from
"
../../notifications/types
"
;
import
type
{
HandlerReturnError
,
HandlerReturnIgnored
,
HandlerReturnType
,
NotificationChannel
,
NotificationData
,
NotificationType
,
PossibleNotificationType
}
from
"
../../notifications/types
"
;
export
async
function
sendNotification
<
T
extends
PossibleNotificationType
>
(
user
:
{
id
:
number
,
notificationChannels
:
NotificationChannel
[]
|
undefined
}
|
number
,
type
:
NotificationType
<
T
>
,
data
:
NotificationData
<
T
>
):
Promise
<
HandlerReturnType
[]
>
{
export
async
function
sendNotification
<
T
extends
PossibleNotificationType
>
(
user
:
{
id
:
number
,
notificationChannels
:
NotificationChannel
[]
|
undefined
}
|
number
,
type
:
NotificationType
<
T
>
,
data
:
NotificationData
<
T
>
):
Promise
<
HandlerReturnType
[]
>
{
let
notificationChannels
:
NotificationChannel
[];
let
notificationChannels
:
NotificationChannel
[];
...
@@ -23,7 +23,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
...
@@ -23,7 +23,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
status
:
"
error
"
,
status
:
"
error
"
,
channel
,
channel
,
error
:
err
error
:
err
}
as
HandlerReturn
Type
;
}
as
HandlerReturn
Error
;
});
});
}
}
case
ChannelType
.
WEBHOOK
.
key
:
{
case
ChannelType
.
WEBHOOK
.
key
:
{
...
@@ -33,7 +33,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
...
@@ -33,7 +33,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
status
:
"
error
"
,
status
:
"
error
"
,
channel
,
channel
,
error
:
err
error
:
err
}
as
HandlerReturn
Type
;
}
as
HandlerReturn
Error
;
});
});
}
}
default
:
{
default
:
{
...
@@ -41,7 +41,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
...
@@ -41,7 +41,7 @@ export async function sendNotification<T extends PossibleNotificationType>(user:
return
{
return
{
status
:
"
ignored
"
,
status
:
"
ignored
"
,
channel
channel
}
as
HandlerReturn
Type
;
}
as
HandlerReturn
Ignored
;
}
}
};
};
}));
}));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment