OctoClient Sharing APIs
This commit is contained in:
parent
1048c009c3
commit
2dab4f56fd
3 changed files with 41 additions and 1 deletions
|
@ -7,8 +7,8 @@ import (
|
||||||
|
|
||||||
type Sharing struct {
|
type Sharing struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Token string `json:"token"`
|
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
Token string `json:"token"`
|
||||||
ModifiedBy string `json:"modifiedBy"`
|
ModifiedBy string `json:"modifiedBy"`
|
||||||
UpdateAt int64 `json:"update_at,omitempty"`
|
UpdateAt int64 `json:"update_at,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
12
webapp/src/blocks/sharing.ts
Normal file
12
webapp/src/blocks/sharing.ts
Normal 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}
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
import {IBlock, IMutableBlock} from './blocks/block'
|
import {IBlock, IMutableBlock} from './blocks/block'
|
||||||
|
import {ISharing} from './blocks/sharing'
|
||||||
import {IUser} from './user'
|
import {IUser} from './user'
|
||||||
import {Utils} from './utils'
|
import {Utils} from './utils'
|
||||||
|
|
||||||
|
@ -203,6 +204,33 @@ class OctoClient {
|
||||||
|
|
||||||
return undefined
|
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') || '')
|
const client = new OctoClient(undefined, localStorage.getItem('sessionId') || '')
|
||||||
|
|
Loading…
Reference in a new issue