사용자의 스페이스 알림 설정 업데이트

이 가이드에서는 Google Chat API의 SpaceNotificationSetting 리소스에서 patch() 메서드를 사용하여 사용자의 스페이스 알림 설정을 업데이트하는 방법을 설명합니다.

SpaceNotificationSetting 리소스는 지정된 사용자의 스페이스 알림 설정에 관한 세부정보를 나타내는 싱글톤 리소스입니다.

기본 요건

Node.js

통화하는 사용자의 스페이스 알림 설정 업데이트

사용자의 스페이스 알림 설정을 업데이트하려면 요청에 다음을 포함합니다.

  • chat.users.spacesettings 승인 범위를 지정합니다.
  • UpdateSpaceNotificationSetting() 메서드를 호출하여 알림 설정의 변경사항을 포함하는 UpdateSpaceNotificationSetting 요청을 전달합니다. 요청에는 다음이 포함됩니다.
    • spaceNotificationSetting: 다음 속성이 있습니다.
      • name 속성은 업데이트할 스페이스 알림 설정을 지정하며 여기에는 사용자 ID 또는 별칭과 스페이스 ID가 포함됩니다. 스페이스 알림 설정을 업데이트하면 호출 사용자의 알림 설정만 업데이트할 수 있으며, 다음 중 하나를 설정하여 지정할 수 있습니다.
        • me 별칭입니다. 예를 들면 users/me/spaces/SPACE/spaceNotificationSetting입니다.
        • 호출 사용자의 Workspace 이메일 주소입니다. 예를 들면 다음과 같습니다. users/user@example.com/spaces/SPACE/spaceNotificationSetting
        • 호출 사용자의 사용자 ID입니다. 예를 들면 다음과 같습니다. users/USER/spaces/SPACE/spaceNotificationSetting
      • notificationSetting: 알림 수준을 설정합니다(예: ALL, OFF).
      • muteSetting: 음소거를 사용 설정 또는 중지합니다. 값은 MUTED 또는 UNMUTED일 수 있습니다.
    • updateMask: 업데이트 필드를 설정합니다. notification_setting, mute_setting를 포함할 수 있습니다.

다음 예에서는 호출 사용자의 스페이스 알림 설정을 업데이트합니다.

Node.js
chat/client-libraries/cloud/update-space-notification-setting-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.users.spacesettings'];

// This sample shows how to update the space notification setting for the calling user
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);

  // Initialize request argument(s), replace the SPACE_NAME with an actual space name.
  const request = {
    spaceNotificationSetting : {
    	name : 'users/me/spaces/SPACE_NAME/spaceNotificationSetting',
    	notificationSetting : 'ALL',
    	muteSetting : 'UNMUTED'
    },
    updateMask : { paths: ['notification_setting','mute_setting']}
  };

  // Make the request
  const response = await chatClient.updateSpaceNotificationSetting(request);

  // Handle the response
  console.log(response);
}

main().catch(console.error);

이 샘플을 실행하려면 SPACE_NAME를 스페이스의 name에 있는 ID로 바꿉니다. ListSpaces() 메서드를 호출하거나 스페이스의 URL에서 ID를 가져올 수 있습니다.

Google Chat API는 지정된 스페이스 알림 설정을 업데이트하고 SpaceNotificationSetting의 인스턴스를 반환합니다.