anchor.diff:          false -> [Item|List]
       end.
   
  +%% 保存聊天记录
  +save_chat(Content, From, To, S) ->
  +    save_message(Content, From, To, chat, S).
  +
  +%% 保存消息历史
  +save_message(Content, From, To, Type, S) ->
  +    case maps:get(account, S, not_login) of
  +        not_login -> not_login;
  +        Account ->
  +            Res = io_lib:format("~ts_chat", [Account]),
  +            Db = ss:nosqlite(Res),
  +            Data = #{<<"content">> => Content,
  +                     <<"from">> => From,
  +                     <<"to">> => To,
  +                     <<"type">> => Type},
  +            Db:create(Data)
  +    end.
  +
  +%% 保存邀请记录
  +save_invite(Type, From, To, S) ->
  +    save_notify("invite", From, To, Type, S).
  +
  +%% 保存通知历史
  +save_notify(Content, From, To, Type, S) ->
  +    case maps:get(account, S, not_login) of
  +        not_login -> not_login;
  +        Account ->
  +            Res = io_lib:format("~ts_notify", [Account]),
  +            Db = ss:nosqlite(Res),
  +            Data = #{<<"content">> => Content,
  +                     <<"from">> => From,
  +                     <<"to">> => To,
  +                     <<"type">> => Type},
  +            Db:create(Data)
  +    end.
positive.code:     end, S).
  
  %% 收到接受邀请的确认
  invite_accept(TrackId, From, #{world:=W, db:=Db, account:= Account, id:=Id}=S) ->
      force_login(fun() ->
          W:send(?offline, [delete, TrackId]),
          Data = Db:find(Id),
          Contacts = maps:get(contacts, S, []),
  
negative.code:             false ->
                  W:send(?offline, [chat_to, Content, Account, To])
          end,
          %% 保存发送记录
          save_chat(Content, Account, To, S),
          {ok, S}
      end, S).
  
  