fix message mutation responses
This commit is contained in:
@@ -2463,7 +2463,13 @@ func (a *adapter) TenantMessageRecall(id t.TenantID, topic string, seq int64, ac
|
|||||||
if err = tx.Commit(); err != nil {
|
if err = tx.Commit(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return a.TenantMessageGetOne(id, topic, seq)
|
msg.UpdatedAt = recalledAt
|
||||||
|
msg.Version++
|
||||||
|
msg.RecalledAt = &recalledAt
|
||||||
|
msg.RecalledBy = actor.String()
|
||||||
|
msg.Head = nil
|
||||||
|
msg.Content = nil
|
||||||
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) TenantGroupMessageRecall(id t.TenantID, topic string, seq int64, actor t.Uid, expectedVersion int, recalledAt time.Time) (*t.Message, error) {
|
func (a *adapter) TenantGroupMessageRecall(id t.TenantID, topic string, seq int64, actor t.Uid, expectedVersion int, recalledAt time.Time) (*t.Message, error) {
|
||||||
@@ -2512,7 +2518,13 @@ func (a *adapter) TenantGroupMessageRecall(id t.TenantID, topic string, seq int6
|
|||||||
if err = tx.Commit(); err != nil {
|
if err = tx.Commit(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return a.TenantGroupMessageGetOne(id, topic, seq)
|
msg.UpdatedAt = recalledAt
|
||||||
|
msg.Version++
|
||||||
|
msg.RecalledAt = &recalledAt
|
||||||
|
msg.RecalledBy = actor.String()
|
||||||
|
msg.Head = nil
|
||||||
|
msg.Content = nil
|
||||||
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) TenantMessageEdit(id t.TenantID, topic string, seq int64, actor t.Uid, expectedVersion int, head t.KVMap, content any, reason string, editedAt time.Time) (*t.Message, error) {
|
func (a *adapter) TenantMessageEdit(id t.TenantID, topic string, seq int64, actor t.Uid, expectedVersion int, head t.KVMap, content any, reason string, editedAt time.Time) (*t.Message, error) {
|
||||||
@@ -2569,7 +2581,13 @@ func (a *adapter) TenantMessageEdit(id t.TenantID, topic string, seq int64, acto
|
|||||||
if err = tx.Commit(); err != nil {
|
if err = tx.Commit(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return a.TenantMessageGetOne(id, topic, seq)
|
msg.UpdatedAt = editedAt
|
||||||
|
msg.Version++
|
||||||
|
msg.Head = head
|
||||||
|
msg.Content = storedContent
|
||||||
|
msg.ContentNonce = nonce
|
||||||
|
msg.KeyVersion = keyVersion
|
||||||
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) TenantGroupMessageEdit(id t.TenantID, topic string, seq int64, actor t.Uid, expectedVersion int, head t.KVMap, content any, reason string, editedAt time.Time) (*t.Message, error) {
|
func (a *adapter) TenantGroupMessageEdit(id t.TenantID, topic string, seq int64, actor t.Uid, expectedVersion int, head t.KVMap, content any, reason string, editedAt time.Time) (*t.Message, error) {
|
||||||
@@ -2625,7 +2643,13 @@ func (a *adapter) TenantGroupMessageEdit(id t.TenantID, topic string, seq int64,
|
|||||||
if err = tx.Commit(); err != nil {
|
if err = tx.Commit(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return a.TenantGroupMessageGetOne(id, topic, seq)
|
msg.UpdatedAt = editedAt
|
||||||
|
msg.Version++
|
||||||
|
msg.Head = head
|
||||||
|
msg.Content = storedContent
|
||||||
|
msg.ContentNonce = nonce
|
||||||
|
msg.KeyVersion = keyVersion
|
||||||
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) TenantMessageGetAll(id t.TenantID, topic string, uid t.Uid, opts *t.QueryOpt) ([]t.Message, error) {
|
func (a *adapter) TenantMessageGetAll(id t.TenantID, topic string, uid t.Uid, opts *t.QueryOpt) ([]t.Message, error) {
|
||||||
|
|||||||
+20
-1
@@ -4360,10 +4360,29 @@ func serveIMGroupMember(wrt http.ResponseWriter, req *http.Request, topic string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func serveIMGroupDetail(wrt http.ResponseWriter, req *http.Request, topic string) {
|
func serveIMGroupDetail(wrt http.ResponseWriter, req *http.Request, topic string) {
|
||||||
principal, selfSub, ok := requireIMGroupMember(wrt, req, topic, true)
|
principal, ok := authenticateIMHTTPBearer(wrt, req)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if types.GetTopicCat(topic) != types.TopicCatGrp {
|
||||||
|
writeIMError(wrt, req, http.StatusBadRequest, 30000, imReasonMalformedRequest, "malformed request", map[string]any{"field": "topic"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.Method == http.MethodGet {
|
||||||
|
if settings, err := store.GroupBusiness.GetSettings(principal.TenantID, topic); err == nil && settings != nil && settings.GroupStatus == types.GroupStatusDissolved {
|
||||||
|
writeIMError(wrt, req, http.StatusGone, 30004, imReasonGroupDissolved, "group dissolved", map[string]any{"topic": topic})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selfSub, err := store.Subs.Get(principal.TenantID, topic, principal.Uid, false)
|
||||||
|
if err != nil {
|
||||||
|
writeIMError(wrt, req, http.StatusInternalServerError, 90000, imReasonInternal, "internal error", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if selfSub == nil || !(selfSub.ModeGiven & selfSub.ModeWant).IsJoiner() || !(selfSub.ModeGiven & selfSub.ModeWant).IsReader() {
|
||||||
|
writeIMError(wrt, req, http.StatusForbidden, 30005, imReasonPermissionDenied, "topic permission required", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
switch req.Method {
|
switch req.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
group, err := store.Topics.Get(principal.TenantID, topic)
|
group, err := store.Topics.Get(principal.TenantID, topic)
|
||||||
|
|||||||
Reference in New Issue
Block a user