fix(friend): verify and synchronize remark updates
Validate the service result before reporting friend remark changes as successful. Rejected, incomplete, or contradictory confirmations now reach callers instead of being reported as completed. Keep confirmed remarks synchronized in the identity cache and consume cross-client remark updates without exposing a new OneBot event. Local cache failures remain observable without turning an already completed remote change into a retryable failure. Preserve friend remarks exactly across restarts and add request, response, persistence, receive-pipeline, and action-level regression coverage. Fixes #303.
This commit is contained in:
17 files changed
+511
-18
No files matched your search
@@ -80,6 +80,18 @@ function makeTempMessage(senderUin: number): TempMessage {
|
||||
}
|
||||
|
||||
describe('convertEvent — message kinds', () => {
|
||||
it('keeps friend remark synchronization internal', async () => {
|
||||
const out = await convertEvent(bareCtx(), {
|
||||
kind: 'friend_remark_changed',
|
||||
time: 1700000000,
|
||||
selfUin: SELF_ID,
|
||||
userUid: 'u_friend',
|
||||
userUin: PEER_UIN,
|
||||
remark: 'new remark',
|
||||
});
|
||||
expect(out).toBeNull();
|
||||
});
|
||||
|
||||
it('friend_message peer → post_type "message", sub_type "friend"', async () => {
|
||||
const out = await convertEvent(bareCtx(), makeFriendMessage(PEER_UIN));
|
||||
expect(out).not.toBeNull();
|
||||
|
||||
@@ -185,6 +185,27 @@ describe('extended-actions / set_self_longnick', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / set_friend_remark', () => {
|
||||
it('reports a confirmed server rejection instead of returning success', async () => {
|
||||
const setFriendRemark = vi.fn(async () => {
|
||||
throw new Error('friend remark was rejected');
|
||||
});
|
||||
const bridge = fakeBridge({ setFriendRemark });
|
||||
|
||||
const response = await makeHandler(fakeCtx(bridge)).handle('set_friend_remark', {
|
||||
user_id: 10001,
|
||||
remark: 'best-friend',
|
||||
});
|
||||
|
||||
expect(setFriendRemark).toHaveBeenCalledWith(10001, 'best-friend');
|
||||
expect(response).toMatchObject({
|
||||
status: 'failed',
|
||||
retcode: 100,
|
||||
wording: 'friend remark was rejected',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / group notice options', () => {
|
||||
it('coerces and forwards every supported announcement option', async () => {
|
||||
const sendNotice = vi.fn(async () => ({ ec: 0 }));
|
||||
|
||||
Reference in new issue
Block a user