Skip to content

Commit

Permalink
Replace notify to_all with to_meeting (#2822)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister authored Sep 18, 2023
1 parent 2a258a3 commit 13c406e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions client/src/app/gateways/notify.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ interface NotifyBase<T> {
*/
export interface NotifyRequest<T> extends NotifyBase<T> {
channel_id: string;
to_all?: boolean;

/**
* Targeted Meeting as MeetingID
Expand Down Expand Up @@ -83,7 +82,7 @@ interface ChannelIdResponse {
interface NotifySendOptions<T> {
name: string;
message: T;
toAll?: boolean;
meeting?: number;
users?: number[];
channels?: string[];
}
Expand Down Expand Up @@ -145,12 +144,17 @@ export class NotifyService extends BaseICCGatewayService<ChannelIdResponse | Not
}

/**
* Sents a notify message to all users (so all clients that are online).
* Sents a notify message to all users of a meeting.
* @param name The name of the notify message
* @param content The payload to send
*/
public async sendToAllUsers<T>(name: string, content: T): Promise<void> {
await this.send(this.buildRequest({ name, message: content, toAll: true }));
* @param meetingId The meeting id to send this message to
*/
public async sendToMeeting<T>(
name: string,
content: T,
meetingId: number = this.activeMeetingIdService.meetingId
): Promise<void> {
await this.send(this.buildRequest({ name, message: content, meeting: meetingId }));
}

/**
Expand Down Expand Up @@ -197,16 +201,16 @@ export class NotifyService extends BaseICCGatewayService<ChannelIdResponse | Not
message: data.message,
channel_id: this.channelId
};
if (data.toAll === true) {
notify.to_all = true;
if (data.meeting) {
notify.to_meeting = data.meeting;
}
if (data.users) {
notify.to_users = data.users;
}
if (data.channels) {
notify.to_channels = data.channels;
}
if (!(data.channels || data.toAll == true || data.users)) {
if (!(data.channels || data.users)) {
notify.to_meeting = this.activeMeetingIdService.meetingId!;
}
return notify;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class ListenEditingDirective extends BaseComponent implements OnDestroy {
if (user) {
this.notifyService.sendToUsers(this.EDIT_NOTIFICATION_NAME, content, user);
} else {
this.notifyService.sendToAllUsers<EditNotification>(this.EDIT_NOTIFICATION_NAME, content);
this.notifyService.sendToMeeting<EditNotification>(this.EDIT_NOTIFICATION_NAME, content);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export class C4DialogComponent implements OnInit, OnDestroy {
*/
public enter_search(): void {
this.caption = this.translate.instant(`Searching for players ...`);
this.notifyService.sendToAllUsers(`c4_search_request`, { name: this.getPlayerName() });
this.notifyService.sendToMeeting(`c4_search_request`, { name: this.getPlayerName() });
}

/**
Expand Down

0 comments on commit 13c406e

Please sign in to comment.