Skip to content

Commit

Permalink
temp fix for acknowledging change notification messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbarron committed Oct 30, 2023
1 parent 7adcbab commit 090deb9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions packages/mgt-chat/src/statefulClient/GraphConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { GraphEndpoint } from '@microsoft/mgt-element';

export class GraphConfig {
public static ackAsString = false;

public static useCanary = false;

public static version = 'v1.0';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export class GraphNotificationClient {
this.processChatPropertiesNotification(notification, emitter);
}
// Need to return a status code string of 200 so that graph knows the message was received and doesn't re-send the notification
return { StatusCode: '200' };
const ackMessage: unknown = { StatusCode: '200' };
return GraphConfig.ackAsString ? JSON.stringify(ackMessage) : ackMessage;
};

private processMessageNotification(notification: Notification<ChatMessage>, emitter: ThreadEventEmitter | undefined) {
Expand Down
1 change: 1 addition & 0 deletions samples/react-chat/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ brokerSettings.renewalThreshold = 65;
brokerSettings.renewalTimerInterval = 15;

// GraphConfig.useCanary = true;
GraphConfig.ackAsString = true;

Providers.globalProvider = new Msal2Provider({
baseURL: GraphConfig.graphEndpoint,
Expand Down
5 changes: 5 additions & 0 deletions samples/react-contoso/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { App } from './App';
import { mergeStyles } from '@fluentui/react';
import { Msal2Provider } from '@microsoft/mgt-msal2-provider';
import { Providers, LoginType } from '@microsoft/mgt-element';
import { GraphConfig } from '@microsoft/mgt-chat';

// Inject some global styles
mergeStyles({
Expand All @@ -14,6 +15,10 @@ mergeStyles({
}
});

// Currently AGS expects the result sent to acknowledge messages as a stringifyed JSON object
// remove this when the change to accept objects rolls out
GraphConfig.ackAsString = true;

Providers.globalProvider = new Msal2Provider({
clientId: process.env.REACT_APP_CLIENT_ID!,
loginType: LoginType.Redirect,
Expand Down

0 comments on commit 090deb9

Please sign in to comment.