1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

OctoClient Sharing APIs

This commit is contained in:
Chen-I Lim 2021-01-12 16:52:25 -08:00
parent 1048c009c3
commit 2dab4f56fd
3 changed files with 41 additions and 1 deletions

View File

@ -7,8 +7,8 @@ import (
type Sharing struct {
ID string `json:"id"`
Token string `json:"token"`
Enabled bool `json:"enabled"`
Token string `json:"token"`
ModifiedBy string `json:"modifiedBy"`
UpdateAt int64 `json:"update_at,omitempty"`
}

View File

@ -0,0 +1,12 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
interface ISharing {
id: string,
enabled: boolean,
token: string,
modifiedBy: string,
updateAt: number,
}
export {ISharing}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {IBlock, IMutableBlock} from './blocks/block'
import {ISharing} from './blocks/sharing'
import {IUser} from './user'
import {Utils} from './utils'
@ -203,6 +204,33 @@ class OctoClient {
return undefined
}
// Sharing
async getSharing(rootId: string): Promise<ISharing> {
const path = `/api/v1/sharing/${rootId}`
const response = await fetch(this.serverUrl + path, {headers: this.headers()})
const sharing = (await response.json()) as ISharing || null
return sharing
}
async setSharing(sharing: ISharing): Promise<boolean> {
const path = `/api/v1/sharing/${sharing.id}`
const body = JSON.stringify(sharing)
const response = await fetch(
this.serverUrl + path,
{
method: 'POST',
headers: this.headers(),
body,
},
)
if (response.status === 200) {
return true
}
return false
}
}
const client = new OctoClient(undefined, localStorage.getItem('sessionId') || '')