fix: resolve P1 backend consistency issues
This commit is contained in:
@@ -7051,15 +7051,17 @@ func (a *adapter) TenantTopicDraftPut(id t.TenantID, uid t.Uid, topic, content s
|
||||
return nil, err
|
||||
}
|
||||
now := t.TimeNow()
|
||||
_, err = a.db.ExecContext(ctx, `INSERT INTO im_topic_drafts
|
||||
res, err := a.db.ExecContext(ctx, `INSERT INTO im_topic_drafts
|
||||
(id,user_id,topic,content,entities_json,version,created_at,updated_at)
|
||||
VALUES(?,?,?,?,?,?,?,?)
|
||||
ON DUPLICATE KEY UPDATE content=VALUES(content),entities_json=VALUES(entities_json),
|
||||
version=version+1,updated_at=VALUES(updated_at)`,
|
||||
ON DUPLICATE KEY UPDATE id=id`,
|
||||
draftID, decodeUID(uid), strings.TrimSpace(topic), content, entities, 1, now, now)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if affected, _ := res.RowsAffected(); affected == 0 {
|
||||
return nil, t.ErrInvalidResponse
|
||||
}
|
||||
return a.topicDraftByKey(ctx, uid, strings.TrimSpace(topic))
|
||||
}
|
||||
res, err := a.db.ExecContext(ctx, `UPDATE im_topic_drafts
|
||||
@@ -9210,6 +9212,13 @@ func (a *adapter) TenantFriendRequestAccept(id t.TenantID, requestID string, act
|
||||
row.HandledAt = &handledAt
|
||||
row.UpdatedAt = handledAt
|
||||
}
|
||||
if _, err = tx.ExecContext(ctx, `UPDATE im_friend_requests SET status=?,handled_at=?,updated_at=?
|
||||
WHERE request_id<>? AND status=? AND
|
||||
((applicant_id=? AND target_id=?) OR (applicant_id=? AND target_id=?))`,
|
||||
t.FriendRequestExpired, handledAt, handledAt, requestID, t.FriendRequestPending,
|
||||
decodeUID(applicant), decodeUID(target), decodeUID(target), decodeUID(applicant)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, pair := range [][2]t.Uid{{applicant, target}, {target, applicant}} {
|
||||
friendshipID, idErr := nextSnowflakeID()
|
||||
if idErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user