Page MenuHomePhorge

Add necessary features to Implement handle matrix uri in kazv
Needs RevisionPublic

Authored by nannanko on Sat, Aug 23, 6:44 AM.
Tags
None
Referenced Files
F7766115: D226.1758585840.diff
Sun, Sep 21, 5:04 PM
F7765279: D226.1758567628.diff
Sun, Sep 21, 12:00 PM
F7765171: D226.1758559778.diff
Sun, Sep 21, 9:49 AM
Subscribers
None

Details

Reviewers
tusooa
Group Reviewers
O1: the Kazv Project
Maniphest Tasks
T29: Parse matrix links
Summary

Add roomId for CreateRoomResponse.

Add Client::addDirectRoom().

Type: add

Test Plan

verify unit tests pass.

Diff Detail

Repository
rL libkazv
Branch
nannanko/create-room-response
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 431
Build 845: GitLab CI for libkazv
Build 844: arc lint + arc unit

Event Timeline

Please add a changelog type to the summary, using the following format:

Type: (add|remove|skip|security|fix)

nannanko removed a reviewer: servant.

Add addDirectRoom() function

nannanko retitled this revision from Add data json for CreateRoomResponse to Add necessary features to Implement handle matrix uri in kazv.
nannanko edited the summary of this revision. (Show Details)

Tests has not been written yet.

tusooa requested changes to this revision.Mon, Sep 8, 4:25 PM
tusooa added inline comments.
src/client/client.cpp
475–489

You should be reusing the content json of the original account data event, not directRoomMap(). directRoomMap is intended to be used as a way to quickly find which user a direct room is associated with. Your code here just convert things back and forth, and is inefficient and error-prone.

This revision now requires changes to proceed.Mon, Sep 8, 4:25 PM

Reusing the content json of the original account data event instead of directRoomMap()

Add comments of param for Client::addDirectRoom()

tusooa requested changes to this revision.Sat, Sep 13, 7:16 PM
tusooa added inline comments.
src/client/client.cpp
476

did not check whether userId is contained in content, can cause UB.

477

did not check whether rooms is a json array

src/tests/client/account-data-test.cpp
471

Add test cases where:

  • the m.direct content contains other users' rooms, then these rooms should be kept.
  • the m.direct content contains the user id but another room, then the new room should be added while keeping existing room(s).
This revision now requires changes to proceed.Sat, Sep 13, 7:16 PM

Check whether userId is contained in content, whether rooms is a json array, and add more test case.

Add GetRoomIdByAliasAction and Client::getRoomIdByAlias()

tusooa requested changes to this revision.Sat, Sep 20, 3:28 PM
tusooa added inline comments.
src/client/actions/alias.cpp
23

refer to the matrix spec for a better grammar for alias.

also, the regex should be static const and the isValidAlias function should be global and static

27

This line is not covered

src/client/actions/alias.hpp
14–18

Should this really be an Action in the ClientModel?

The problem with it being an action is that it cannot happen at the same time with other actions -- this is useful to avoid race conditions when the reducer needs to access the model and change it based on the current. But your reducer does not actually need to access the model except server url and access token (which we consider to be unlikely to change).

This means that it might have to wait for the potential heavy computing in another reducer before it can give you back the results.

Maybe a function that returns a BaseJob + a function that parses a Response will be a better idea.

BaseJob getRoomIdByAliasJob(std::string alias) const;
static std::string parseGetRoomIdByAliasResponse(...) const;
This revision now requires changes to proceed.Sat, Sep 20, 3:28 PM