This repository was archived by the owner on Nov 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Adds SubscriptionRead and ISubscriptionBridge #43
Open
marceloschmidt
wants to merge
14
commits into
alpha
Choose a base branch
from
subscription-read
base: alpha
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9f9b7af
Adds SubscriptionRead and ISubscriptionBridge
marceloschmidt 0fd7864
Return IterableIterator of ISubscription, instead of single item
marceloschmidt 01455a5
Adds definition for ISubscription
marceloschmidt c85a7aa
Fix importing ISubscription
marceloschmidt acb3d2c
Various code style changes
graywolf336 bade966
Add more fields to the subscription interface with documentation.
graywolf336 bd15cc0
Rename the subscriptions to be room subscriptions
graywolf336 de72a0a
Let's try an async iterable iterator
graywolf336 8556115
Revert async iterable iterator for subscriptions
graywolf336 9cd1a14
Merge master down into the subscription-read branch
graywolf336 37045f5
Reimplement the AsyncIterableIterator for the SubscriptionRead interface
graywolf336 8a730a3
Use the esnext library when compiling apps
graywolf336 1e60dbb
Merge branch 'alpha' into subscription-read
graywolf336 b83acd8
Remove the specific iterator and go generic
graywolf336 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,23 @@ | ||
| import { IRoomSubscription } from '../subscriptions'; | ||
|
|
||
| /** | ||
| * This accessor provides methods for accessing | ||
| * subscriptions in a read-only-fashion. | ||
| */ | ||
| export interface IRoomSubscriptionRead { | ||
| /** | ||
| * Gets a list of subscriptions by a room id. | ||
| * | ||
| * @param roomId the id of the room | ||
| * @returns an iterator of subscriptions | ||
| */ | ||
| getByRoomId(roomId: string): Promise<AsyncIterableIterator<IRoomSubscription>>; | ||
|
|
||
| /** | ||
| * Gets a list of all the subscriptions for a user by their id. | ||
| * | ||
| * @param userId the id of the user | ||
| * @returns an iterator of subscriptions for the user | ||
| */ | ||
| getByUserId(userId: string): Promise<AsyncIterableIterator<IRoomSubscription>>; | ||
| } |
This file contains hidden or 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 hidden or 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,32 @@ | ||
| import { IRoom } from '../rooms'; | ||
| import { IUser } from '../users'; | ||
|
|
||
| /** | ||
| * This interface represents a user's subscription to | ||
| * a room and includes information about that user's | ||
| * settings and information in relation to the room. | ||
| */ | ||
| export interface IRoomSubscription { | ||
| /** The id of the subscription (maps to `_id`). */ | ||
| id: string; | ||
| /** The room the subscription is for (kinda maps to `rid`). */ | ||
| room: IRoom; | ||
| /** The user the subscription is for (kinda maps to `u`). */ | ||
| user: IUser; | ||
| /** Whether the room the subscription is for is hidden from the UI (maps to `open`). */ | ||
| isHidden: boolean; | ||
| /** Whether the subscription has an alert or notification for the user (maps to `alert`). */ | ||
| hasAlert: boolean; | ||
| /** The actual number to display on the room's list; it is the sum of userMentionsCount and groupMentionsCount (maps to `unread`). */ | ||
| unreadCount: number; | ||
| /** The number of times the user has been mentioned (maps to `userMentions`). */ | ||
| userMentionsCount: number; | ||
| /** The number of times the groups a user is part of has been mentioned (maps to `groupMentions`). */ | ||
| groupMentionsCount: number; | ||
| /** The date when the subscription was created (maps to `ts`). */ | ||
| createdAt: Date; | ||
| /** The date when the subscription was last updated (maps to `_updatedAt`). */ | ||
| updatedAt?: Date; | ||
| /** The last date/time the subscription was seen or marked as read (maps to `ls`). */ | ||
| lastSeenAt?: Date; | ||
| } |
This file contains hidden or 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 @@ | ||
| export { IRoomSubscription } from './IRoomSubscription'; |
This file contains hidden or 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 hidden or 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,16 @@ | ||
| import { IRoomSubscriptionRead } from '../../definition/accessors'; | ||
| import { IRoomSubscription } from '../../definition/subscriptions'; | ||
|
|
||
| import { IRoomSubscriptionBridge } from '../bridges'; | ||
|
|
||
| export class RoomSubscriptionRead implements IRoomSubscriptionRead { | ||
| constructor(private subscriptionBridge: IRoomSubscriptionBridge, private appId: string) { } | ||
|
|
||
| public getByRoomId(roomId: string): Promise<AsyncIterableIterator<IRoomSubscription>> { | ||
| return this.subscriptionBridge.getByRoomId(roomId, this.appId); | ||
| } | ||
|
|
||
| public getByUserId(userId: string): Promise<AsyncIterableIterator<IRoomSubscription>> { | ||
| return this.subscriptionBridge.getByUserId(userId, this.appId); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
| import { IRoomSubscription } from '../../definition/subscriptions'; | ||
|
|
||
| export interface IRoomSubscriptionBridge { | ||
| getByRoomId(roomId: string, appId: string): Promise<AsyncIterableIterator<IRoomSubscription>>; | ||
|
|
||
| getByUserId(userId: string, appId: string): Promise<AsyncIterableIterator<IRoomSubscription>>; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| import { IRoomSubscription } from '../../../src/definition/subscriptions'; | ||
| import { IRoomSubscriptionBridge } from '../../../src/server/bridges'; | ||
|
|
||
| export class TestsSubscriptionBridge implements IRoomSubscriptionBridge { | ||
| public getByRoomId(roomId: string, appId: string): Promise<AsyncIterableIterator<IRoomSubscription>> { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
|
|
||
| public getByUserId(userId: string, appId: string): Promise<AsyncIterableIterator<IRoomSubscription>> { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.