diff --git a/doc/api.oa3 b/doc/api.oa3
index 3c96fbe0..e7e027cc 100644
--- a/doc/api.oa3
+++ b/doc/api.oa3
@@ -2113,7 +2113,7 @@ paths:
schema:
$ref: '#/components/schemas/ChannelParams'
- /content/channels/{channelId}:
+ /content/channels/{channelId}/detail:
get:
tags:
- content
@@ -2143,6 +2143,8 @@ paths:
description: account disabled
'500':
description: internal server error
+
+/content/channels/{channelId}:
delete:
tags:
- content
@@ -2869,7 +2871,7 @@ paths:
content:
application/json:
schema:
- type: boolean
+ type: string
/content/channels/{channelId}/topics/{topicId}/tags:
diff --git a/net/server/internal/api_getChannel.go b/net/server/internal/api_getChannel.go
index 59332721..56d37836 100644
--- a/net/server/internal/api_getChannel.go
+++ b/net/server/internal/api_getChannel.go
@@ -16,16 +16,16 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
var guid string
var act *store.Account
- tokenType := r.Header.Get("TokenType")
+ tokenType := ParamTokenType(r)
if tokenType == APP_TOKENAGENT {
- account, code, err := BearerAppToken(r, false);
+ account, code, err := ParamAgentToken(r, false);
if err != nil {
ErrResponse(w, code, err)
return
}
act = account
} else if tokenType == APP_TOKENCONTACT {
- card, code, err := BearerContactToken(r, true)
+ card, code, err := ParamContactToken(r, true)
if err != nil {
ErrResponse(w, code, err)
return
diff --git a/net/server/internal/api_getChannelTopic.go b/net/server/internal/api_getChannelTopic.go
index eea15a4c..34d25ca8 100644
--- a/net/server/internal/api_getChannelTopic.go
+++ b/net/server/internal/api_getChannelTopic.go
@@ -62,16 +62,16 @@ func getChannelSlot(r *http.Request, member bool) (slot store.ChannelSlot, guid
// validate contact access
var account *store.Account
- tokenType := r.Header.Get("TokenType")
+ tokenType := ParamTokenType(r);
if tokenType == APP_TOKENAGENT {
- account, code, err = BearerAppToken(r, false);
+ account, code, err = ParamAgentToken(r, false);
if err != nil {
return
}
guid = account.Guid
} else if tokenType == APP_TOKENCONTACT {
var card *store.Card
- card, code, err = BearerContactToken(r, true)
+ card, code, err = ParamContactToken(r, true)
if err != nil {
return
}
diff --git a/net/server/internal/api_setChannelTopicSubject.go b/net/server/internal/api_setChannelTopicSubject.go
index 2dde18b6..ced184be 100644
--- a/net/server/internal/api_setChannelTopicSubject.go
+++ b/net/server/internal/api_setChannelTopicSubject.go
@@ -29,7 +29,7 @@ func SetChannelTopicSubject(w http.ResponseWriter, r *http.Request) {
// load topic
var topicSlot store.TopicSlot
- if err = store.DB.Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil {
+ if err = store.DB.Preload("Topic").Where("channel_id = ? AND topic_slot_id = ?", channelSlot.Channel.ID, topicId).First(&topicSlot).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
ErrResponse(w, http.StatusNotFound, err)
} else {
diff --git a/net/server/internal/routers.go b/net/server/internal/routers.go
index eeeb3b61..dac14774 100644
--- a/net/server/internal/routers.go
+++ b/net/server/internal/routers.go
@@ -541,7 +541,7 @@ var routes = Routes{
Route{
"GetChannel",
strings.ToUpper("Get"),
- "/content/channels/{channelId}",
+ "/content/channels/{channelId}/detail",
GetChannel,
},
diff --git a/net/server/internal/testUtil.go b/net/server/internal/testUtil.go
index 1991a663..e6b04c25 100644
--- a/net/server/internal/testUtil.go
+++ b/net/server/internal/testUtil.go
@@ -196,18 +196,28 @@ func ApiTestUpload(
return
}
+ if tokenType == APP_TOKENAGENT {
+ if !strings.Contains(name, "?") {
+ name += "?"
+ } else {
+ name += "&"
+ }
+ name += "agent=" + token
+ } else if tokenType == APP_TOKENCONTACT {
+ if !strings.Contains(name, "?") {
+ name += "?"
+ } else {
+ name += "&"
+ }
+ name += "contact=" + token
+ }
+
w := httptest.NewRecorder()
r := httptest.NewRequest(requestType, name, &data)
if params != nil {
r = mux.SetURLVars(r, *params)
}
- if tokenType != "" {
- r.Header.Add("TokenType", tokenType)
- }
- if token != "" {
- SetBearerAuth(r, token)
- }
r.Header.Set("Content-Type", writer.FormDataContentType())
endpoint(w, r)
diff --git a/net/web/src/Api/addChannelTopic.js b/net/web/src/Api/addChannelTopic.js
new file mode 100644
index 00000000..bc41a320
--- /dev/null
+++ b/net/web/src/Api/addChannelTopic.js
@@ -0,0 +1,24 @@
+import { checkResponse, fetchWithTimeout } from './fetchUtil';
+
+export async function addChannelTopic(token, channelId, message, assets ) {
+ let topic = await fetchWithTimeout(`/content/channels/${channelId}/topics?agent=${token}`,
+ { method: 'POST', body: JSON.stringify({}) });
+ checkResponse(topic);
+ let slot = await topic.json();
+
+ // add each asset
+
+ let subject = { data: JSON.stringify(message, (key, value) => {
+ if (value !== null) return value
+ }), datatype: 'superbasictopic' };
+ let unconfirmed = await fetchWithTimeout(`/content/channels/${channelId}/topics/${slot.id}/subject?agent=${token}`,
+ { method: 'PUT', body: JSON.stringify(subject) });
+ checkResponse(unconfirmed);
+
+ let confirmed = await fetchWithTimeout(`/content/channels/${channelId}/topics/${slot.id}/confirmed?agent=${token}`,
+ { method: 'PUT', body: JSON.stringify('confirmed') });
+ checkResponse(confirmed);
+
+ return;
+}
+
diff --git a/net/web/src/Api/getChannel.js b/net/web/src/Api/getChannel.js
new file mode 100644
index 00000000..27d58d1a
--- /dev/null
+++ b/net/web/src/Api/getChannel.js
@@ -0,0 +1,8 @@
+import { checkResponse, fetchWithTimeout } from './fetchUtil';
+
+export async function getChannel(token, channelId) {
+ let channel = await fetchWithTimeout(`/content/channels/${channelId}/detail?agent=${token}`, { method: 'GET' });
+ checkResponse(channel)
+ return await channel.json()
+}
+
diff --git a/net/web/src/Api/getChannels.js b/net/web/src/Api/getChannels.js
index 0312712c..85af261c 100644
--- a/net/web/src/Api/getChannels.js
+++ b/net/web/src/Api/getChannels.js
@@ -3,7 +3,7 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getChannels(token, revision) {
let param = "?agent=" + token
if (revision != null) {
- param += '&revision=' + revision
+ param += '&channelRevision=' + revision
}
let channels = await fetchWithTimeout('/content/channels' + param, { method: 'GET' });
checkResponse(channels)
diff --git a/net/web/src/App.js b/net/web/src/App.js
index e99f307c..5295d262 100644
--- a/net/web/src/App.js
+++ b/net/web/src/App.js
@@ -26,7 +26,8 @@ function App() {