-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,847 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module default { | ||
abstract type Notification extending Mixin::Audited { | ||
readAt := .currentRecipient.readAt; | ||
unread := not exists .currentRecipient.readAt; | ||
single currentRecipient := assert_single(( | ||
select .recipients filter .user = global currentUser | ||
)); | ||
recipients := .<notification[is Notification::Recipient]; | ||
} | ||
} | ||
|
||
module Notification { | ||
type Recipient { | ||
required notification: default::Notification { | ||
on target delete delete source; | ||
}; | ||
required user: default::User { | ||
on target delete delete source; | ||
}; | ||
|
||
readAt: datetime; | ||
} | ||
|
||
type System extending default::Notification { | ||
required message: str; | ||
} | ||
abstract type Comment extending default::Notification { | ||
required comment: Comments::Comment { | ||
on target delete delete source; | ||
}; | ||
} | ||
type CommentViaMention extending Comment; | ||
type CommentViaMembership extending Comment; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/components/authorization/policies/by-feature/everyone-can-comment.policy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Policy } from '../util'; | ||
|
||
@Policy('all', (r) => [ | ||
// Technically, we want only when the Commentable is readable. | ||
// I think this is sufficient for practical use at this point in time. | ||
...[r.CommentThread, r.Comment].flatMap((it) => it.read.create), | ||
// This shouldn't be needed, but it is. children() needs rewrite. | ||
r.Commentable.children((c) => c.commentThreads.read.create), | ||
]) | ||
export class EveryoneCanCommentPolicy {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/components/comments/mention-notification/comment-via-mention-notification.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ObjectType } from '@nestjs/graphql'; | ||
import { keys as keysOf } from 'ts-transformer-keys'; | ||
import { SecuredProps } from '~/common'; | ||
import { e } from '~/core/edgedb'; | ||
import { LinkTo, RegisterResource } from '~/core/resources'; | ||
import { Notification } from '../../notifications'; | ||
|
||
@RegisterResource({ db: e.Notification.CommentViaMention }) | ||
@ObjectType({ | ||
implements: [Notification], | ||
}) | ||
export class CommentViaMentionNotification extends Notification { | ||
static readonly Props = keysOf<CommentViaMentionNotification>(); | ||
static readonly SecuredProps = | ||
keysOf<SecuredProps<CommentViaMentionNotification>>(); | ||
|
||
readonly comment: LinkTo<'Comment'>; | ||
} | ||
|
||
declare module '~/core/resources/map' { | ||
interface ResourceMap { | ||
CommentMentionedNotification: typeof CommentViaMentionNotification; | ||
} | ||
interface ResourceDBMap { | ||
CommentMentionedNotification: typeof e.Notification.CommentViaMention; | ||
} | ||
} |
Oops, something went wrong.