|
Ring Daemon
|
This class gives access to the git repository that represents the conversation. More...
#include <conversationrepository.h>

Classes | |
| class | Impl |
Public Member Functions | |
| std::string | addMember (const std::string &uri) |
| Write the certificate in /members and commit the change. | |
| std::string | amend (const std::string &id, const std::string &msg) |
| Amend a commit message. | |
| std::string | commitMessage (const std::string &msg, bool verifyDevice=true) |
| Add a new commit to the conversation. | |
| std::vector< std::string > | commitMessages (const std::vector< std::string > &msgs) |
| std::vector< std::map< std::string, std::string > > | convCommitsToMap (const std::vector< ConversationCommit > &commits) const |
| Convert ConversationCommit to MapStringString for the client. | |
| std::optional< std::map< std::string, std::string > > | convCommitToMap (const ConversationCommit &commit) const |
| ConversationRepository (const std::shared_ptr< JamiAccount > &account, const std::string &id) | |
| Open a conversation repository for an account and an id. | |
| std::map< std::string, std::vector< DeviceId > > | devices (bool ignoreExpired=true) const |
| Get conversation's devices. | |
| std::string | diffStats (const std::string &newId, const std::string &oldId="") const |
| Get current diff stats between two commits. | |
| void | erase () |
| Erase repository. | |
| bool | fetch (const std::string &remoteDeviceId) |
| Fetch a remote repository via the given socket. | |
| std::optional< ConversationCommit > | getCommit (const std::string &commitId) const |
| std::string | getHead () const |
| Get current HEAD hash. | |
| std::vector< std::string > | getInitialMembers () const |
| One to one util, get initial members. | |
| bool | hasCommit (const std::string &commitId) const |
| Check if a commit exists in the repository. | |
| const std::string & | id () const |
| Return the conversation id. | |
| std::map< std::string, std::string > | infos () const |
| Retrieve current infos (title, description, avatar, mode) | |
| bool | isValidUserAtCommit (const std::string &userDevice, const std::string &commitId, const git_buf &sig, const git_buf &sig_data) const |
| Verify the signature against the given commit. | |
| std::string | join () |
| Join a repository. | |
| std::string | leave () |
| Erase self from repository. | |
| std::optional< std::string > | linearizedParent (const std::string &commitId) const |
| Get parent via topological + date sort in branch main of a commit. | |
| std::vector< ConversationCommit > | log (const LogOptions &options={}) const |
| Get commits depending on the options we pass. | |
| void | log (PreConditionCb &&preCondition, std::function< void(ConversationCommit &&)> &&emplaceCb, PostConditionCb &&postCondition, const std::string &from="", bool logIfNotFound=true) const |
| std::vector< ConversationMember > | members () const |
| Get conversation's members. | |
| std::set< std::string > | memberUris (std::string_view filter, const std::set< MemberRole > &filteredRoles) const |
| std::pair< bool, std::string > | merge (const std::string &merge_id, bool force=false) |
| Merge another branch into the main branch. | |
| std::vector< std::map< std::string, std::string > > | mergeHistory (const std::string &uri, std::function< void(const std::string &)> &&disconnectFromPeerCb={}) |
| Merge the history of the conversation with another peer. | |
| ConversationMode | mode () const |
| Get conversation's mode. | |
| void | onMembersChanged (OnMembersChanged &&cb) |
| void | pinCertificates (bool blocking=false) |
| Because conversations can contains non contacts certificates, this methods loads certificates in conversations into the cert store. | |
| void | refreshMembers () const |
| To use after a merge with member's events, refresh members knowledge. | |
| std::string | remoteHead (const std::string &remoteDeviceId, const std::string &branch="main") const |
| Retrieve remote head. | |
| void | removeBranchWith (const std::string &remoteDevice) |
| Delete branch with remote. | |
| std::string | resolveVote (const std::string &uri, const std::string_view type, const std::string &voteType) |
| Validate if a vote is finished. | |
| std::string | updateInfos (const std::map< std::string, std::string > &map) |
| Change repository's infos. | |
| std::string | uriFromDevice (const std::string &deviceId) const |
| Retrieve the uri from a deviceId. | |
| std::pair< std::vector< ConversationCommit >, bool > | validClone () const |
| Validate a clone. | |
| bool | validCommits (const std::vector< ConversationCommit > &commitsToValidate) const |
| Validate that commits are not malformed. | |
| std::pair< std::vector< ConversationCommit >, bool > | validFetch (const std::string &remoteDevice) const |
| Validate a fetch with remote device. | |
| std::string | voteKick (const std::string &uri, const std::string &type) |
| The voting system is divided in two parts. | |
| std::string | voteUnban (const std::string &uri, const std::string_view type) |
| Add a vote to re-add a user. | |
| ~ConversationRepository () | |
Static Public Member Functions | |
| static std::vector< std::string > | changedFiles (std::string_view diffStats) |
| Get changed files from a git diff. | |
| static LIBJAMI_TEST_EXPORT std::pair< std::unique_ptr< ConversationRepository >, std::vector< ConversationCommit > > | cloneConversation (const std::shared_ptr< JamiAccount > &account, const std::string &deviceId, const std::string &conversationId) |
| Clones a conversation on a remote device. | |
| static LIBJAMI_TEST_EXPORT std::unique_ptr< ConversationRepository > | createConversation (const std::shared_ptr< JamiAccount > &account, ConversationMode mode=ConversationMode::INVITES_ONLY, const std::string &otherMember="") |
| Creates a new repository, with initial files, where the first commit hash is the conversation id. | |
| static std::map< std::string, std::string > | infosFromVCard (vCard::utils::VCardData &&details) |
This class gives access to the git repository that represents the conversation.
Definition at line 133 of file conversationrepository.h.
| jami::ConversationRepository::ConversationRepository | ( | const std::shared_ptr< JamiAccount > & | account, |
| const std::string & | id | ||
| ) |
Open a conversation repository for an account and an id.
| account | The related account |
| id | The conversation id |
Definition at line 3165 of file conversationrepository.cpp.
|
default |
| std::string jami::ConversationRepository::addMember | ( | const std::string & | uri | ) |
Write the certificate in /members and commit the change.
| uri | Member to add |
Definition at line 3178 of file conversationrepository.cpp.
References jami::emitSignal(), jami::INVITED, jami::MemberPath::INVITED, JAMI_ERROR, JAMI_WARNING, and jami::json::toString().

Amend a commit message.
| id | The commit to amend |
| msg | The commit message of the commit |
Definition at line 3232 of file conversationrepository.cpp.
References jami::ECOMMIT, jami::emitSignal(), JAMI_DEBUG, JAMI_ERROR, and JAMI_WARNING.

|
static |
Get changed files from a git diff.
| diffStats | The stats to analyze |
Definition at line 3678 of file conversationrepository.cpp.
References changedFiles(), diffStats(), jami::emitSignal(), jami::getline(), and std::regex_search().
Referenced by changedFiles(), jami::ConversationRepository::Impl::checkInitialCommit(), jami::ConversationRepository::Impl::checkValidAdd(), jami::ConversationRepository::Impl::checkValidJoins(), jami::ConversationRepository::Impl::checkValidProfileUpdate(), jami::ConversationRepository::Impl::checkValidRemove(), jami::ConversationRepository::Impl::checkValidUserDiff(), jami::ConversationRepository::Impl::checkValidVoteResolution(), and jami::ConversationRepository::Impl::checkVote().

|
static |
Clones a conversation on a remote device.
| account | The account getting the conversation |
| deviceId | Remote device |
| conversationId | Conversation to clone |
Definition at line 2779 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::get_data_dir(), JAMI_DEBUG, JAMI_ERROR, JAMI_LOG, JAMI_WARNING, and MAX_FETCH_SIZE.

| std::string jami::ConversationRepository::commitMessage | ( | const std::string & | msg, |
| bool | verifyDevice = true |
||
| ) |
Add a new commit to the conversation.
| msg | The commit message of the commit |
| verifyDevice | If we need to validate that certificates are correct (used for testing) |
Definition at line 3478 of file conversationrepository.cpp.
References jami::emitSignal().

| std::vector< std::string > jami::ConversationRepository::commitMessages | ( | const std::vector< std::string > & | msgs | ) |
Definition at line 3493 of file conversationrepository.cpp.
References jami::emitSignal().

| std::vector< std::map< std::string, std::string > > jami::ConversationRepository::convCommitsToMap | ( | const std::vector< ConversationCommit > & | commits | ) | const |
Convert ConversationCommit to MapStringString for the client.
Definition at line 4354 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by mergeHistory().

| std::optional< std::map< std::string, std::string > > jami::ConversationRepository::convCommitToMap | ( | const ConversationCommit & | commit | ) | const |
Definition at line 4348 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::checkEdit().
|
static |
Creates a new repository, with initial files, where the first commit hash is the conversation id.
| account | The related account |
| mode | The wanted mode |
| otherMember | The other uri |
Definition at line 2726 of file conversationrepository.cpp.
References jami::add_initial_files(), jami::create_empty_repository(), jami::emitSignal(), jami::fileutils::get_data_dir(), id(), jami::initial_commit(), JAMI_ERROR, JAMI_LOG, and mode().

| std::map< std::string, std::vector< DeviceId > > jami::ConversationRepository::devices | ( | bool | ignoreExpired = true | ) | const |
Get conversation's devices.
| ignoreExpired | If we want to ignore expired devices |
Definition at line 4165 of file conversationrepository.cpp.
References jami::emitSignal().

| std::string jami::ConversationRepository::diffStats | ( | const std::string & | newId, |
| const std::string & | oldId = "" |
||
| ) | const |
Get current diff stats between two commits.
| oldId | Old commit |
| newId | Recent commit (empty value will compare to the empty repository) |
Definition at line 3672 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by changedFiles(), jami::ConversationRepository::Impl::checkInitialCommit(), jami::ConversationRepository::Impl::checkValidAdd(), jami::ConversationRepository::Impl::checkValidJoins(), jami::ConversationRepository::Impl::checkValidProfileUpdate(), jami::ConversationRepository::Impl::checkValidRemove(), jami::ConversationRepository::Impl::checkValidUserDiff(), jami::ConversationRepository::Impl::checkValidVoteResolution(), jami::ConversationRepository::Impl::checkVote(), and jami::ConversationRepository::Impl::diffStats().

| void jami::ConversationRepository::erase | ( | ) |
Erase repository.
Definition at line 3834 of file conversationrepository.cpp.
References jami::emitSignal(), and JAMI_LOG.

Fetch a remote repository via the given socket.
| remoteDeviceId | Remote device id to fetch |
Definition at line 3277 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::get_data_dir(), JAMI_ERROR, JAMI_WARNING, and MAX_FETCH_SIZE.

| std::optional< ConversationCommit > jami::ConversationRepository::getCommit | ( | const std::string & | commitId | ) | const |
Definition at line 3526 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by jami::ConversationRepository::Impl::checkEdit(), jami::ConversationRepository::Impl::getInitialMembers(), mergeHistory(), and jami::ConversationRepository::Impl::mode().

| std::string jami::ConversationRepository::getHead | ( | ) | const |
Get current HEAD hash.
Definition at line 4333 of file conversationrepository.cpp.
References jami::emitSignal(), and JAMI_ERROR.

| std::vector< std::string > jami::ConversationRepository::getInitialMembers | ( | ) | const |
One to one util, get initial members.
Definition at line 4147 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::checkValidAdd(), and jami::ConversationRepository::Impl::initMembers().
Check if a commit exists in the repository.
| commitId | The commit id to check |
Definition at line 3520 of file conversationrepository.cpp.
References jami::emitSignal().

| const std::string & jami::ConversationRepository::id | ( | ) | const |
Return the conversation id.
Definition at line 3172 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::convCommitToMap(), and createConversation().
| std::map< std::string, std::string > jami::ConversationRepository::infos | ( | ) | const |
Retrieve current infos (title, description, avatar, mode)
Definition at line 4291 of file conversationrepository.cpp.
References jami::emitSignal(), infosFromVCard(), jami::fileutils::loadFile(), mode(), and jami::vCard::utils::toMap().
Referenced by updateInfos().

|
static |
Definition at line 4313 of file conversationrepository.cpp.
References jami::vCard::Property::DESCRIPTION, jami::emitSignal(), jami::vCard::Property::FORMATTED_NAME, jami::vCard::Property::PHOTO, jami::vCard::Property::RDV_ACCOUNT, and jami::vCard::Property::RDV_DEVICE.
Referenced by infos(), and jami::ConversationModule::onTrustRequest().

| bool jami::ConversationRepository::isValidUserAtCommit | ( | const std::string & | userDevice, |
| const std::string & | commitId, | ||
| const git_buf & | sig, | ||
| const git_buf & | sig_data | ||
| ) | const |
Verify the signature against the given commit.
| userDevice | the email of the sender (i.e. their device's public key) |
| commitId | the id of the commit |
Definition at line 4118 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by jami::ConversationRepository::Impl::validCommits().

| std::string jami::ConversationRepository::join | ( | ) |
Join a repository.
Definition at line 3693 of file conversationrepository.cpp.
References jami::MemberPath::ADMINS, jami::emitSignal(), jami::fileutils::getFullPath(), jami::git_add_all(), jami::MemberPath::INVITED, JAMI_ERROR, jami::MEMBER, jami::MemberPath::MEMBERS, and jami::json::toString().

| std::string jami::ConversationRepository::leave | ( | ) |
Erase self from repository.
Definition at line 3763 of file conversationrepository.cpp.
References jami::MemberPath::ADMINS, jami::emitSignal(), jami::git_add_all(), jami::fileutils::loadFile(), jami::MemberPath::MEMBERS, and jami::json::toString().

| std::optional< std::string > jami::ConversationRepository::linearizedParent | ( | const std::string & | commitId | ) | const |
Get parent via topological + date sort in branch main of a commit.
| commitId | id to choice |
| std::vector< ConversationCommit > jami::ConversationRepository::log | ( | const LogOptions & | options = {} | ) | const |
Get commits depending on the options we pass.
Definition at line 3504 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by jami::ConversationRepository::Impl::behind(), and validClone().

| void jami::ConversationRepository::log | ( | PreConditionCb && | preCondition, |
| std::function< void(ConversationCommit &&)> && | emplaceCb, | ||
| PostConditionCb && | postCondition, | ||
| const std::string & | from = "", |
||
| bool | logIfNotFound = true |
||
| ) | const |
Definition at line 3510 of file conversationrepository.cpp.
References jami::emitSignal().

| std::vector< ConversationMember > jami::ConversationRepository::members | ( | ) | const |
Get conversation's members.
Definition at line 4153 of file conversationrepository.cpp.
| std::set< std::string > jami::ConversationRepository::memberUris | ( | std::string_view | filter, |
| const std::set< MemberRole > & | filteredRoles | ||
| ) | const |
| filter | If we want to remove one member |
| filteredRoles | If we want to ignore some roles |
Definition at line 4159 of file conversationrepository.cpp.
References jami::emitSignal().

| std::pair< bool, std::string > jami::ConversationRepository::merge | ( | const std::string & | merge_id, |
| bool | force = false |
||
| ) |
Merge another branch into the main branch.
| merge_id | The reference to merge |
| force | Should be false, skip validateDevice() ; used for test purpose |
Definition at line 3532 of file conversationrepository.cpp.
References jami::emitSignal(), jami::git_add_all(), JAMI_ERROR, and JAMI_LOG.
Referenced by mergeHistory().

| std::vector< std::map< std::string, std::string > > jami::ConversationRepository::mergeHistory | ( | const std::string & | uri, |
| std::function< void(const std::string &)> && | disconnectFromPeerCb = {} |
||
| ) |
Merge the history of the conversation with another peer.
| uri | The peer uri |
| disconnectFromPeerCb | Callback to disconnect from peer when banning |
Definition at line 3347 of file conversationrepository.cpp.
References convCommitsToMap(), jami::emitSignal(), getCommit(), JAMI_ERROR, JAMI_LOG, JAMI_WARNING, merge(), refreshMembers(), remoteHead(), removeBranchWith(), and validFetch().

| ConversationMode jami::ConversationRepository::mode | ( | ) | const |
Get conversation's mode.
Definition at line 3845 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::checkInitialCommit(), jami::ConversationRepository::Impl::checkValidAdd(), jami::ConversationRepository::Impl::checkValidUserDiff(), createConversation(), jami::ConversationRepository::Impl::getInitialMembers(), infos(), jami::ConversationRepository::Impl::initMembers(), and jami::ConversationRepository::Impl::mode().
| void jami::ConversationRepository::onMembersChanged | ( | OnMembersChanged && | cb | ) |
Definition at line 3226 of file conversationrepository.cpp.
References jami::emitSignal().

Because conversations can contains non contacts certificates, this methods loads certificates in conversations into the cert store.
| blocking | if we need to wait that certificates are pinned |
Definition at line 4180 of file conversationrepository.cpp.
References jami::MemberPath::ADMINS, jami::MemberPath::DEVICES, jami::emitSignal(), and jami::MemberPath::MEMBERS.

| void jami::ConversationRepository::refreshMembers | ( | ) | const |
To use after a merge with member's events, refresh members knowledge.
Definition at line 4171 of file conversationrepository.cpp.
Referenced by mergeHistory().
| std::string jami::ConversationRepository::remoteHead | ( | const std::string & | remoteDeviceId, |
| const std::string & | branch = "main" |
||
| ) | const |
Retrieve remote head.
Can be useful after a fetch operation
| remoteDeviceId | The remote name |
| branch | Remote branch to check (default: main) |
Definition at line 3400 of file conversationrepository.cpp.
References jami::emitSignal(), JAMI_ERROR, JAMI_WARNING, and remoteHead().
Referenced by mergeHistory(), remoteHead(), and validFetch().

Delete branch with remote.
| remoteDevice |
Definition at line 4133 of file conversationrepository.cpp.
References jami::emitSignal(), and JAMI_WARNING.
Referenced by mergeHistory().

| std::string jami::ConversationRepository::resolveVote | ( | const std::string & | uri, |
| const std::string_view | type, | ||
| const std::string & | voteType | ||
| ) |
Validate if a vote is finished.
| uri | identified of the user/device |
| type | device, members, admins or invited |
| voteType | "ban" or "unban" |
Definition at line 4041 of file conversationrepository.cpp.
References jami::MemberPath::ADMINS, jami::emitSignal(), jami::fileutils::getFullPath(), jami::git_add_all(), JAMI_WARNING, and jami::json::toString().

| std::string jami::ConversationRepository::updateInfos | ( | const std::map< std::string, std::string > & | map | ) |
Change repository's infos.
| map | New infos (supported keys: title, description, avatar) |
Definition at line 4211 of file conversationrepository.cpp.
References jami::vCard::Value::AVATAR, jami::vCard::Property::BASE64, jami::vCard::Delimiter::BEGIN_TOKEN, jami::vCard::Property::DESCRIPTION, jami::vCard::Value::DESCRIPTION, jami::emitSignal(), jami::vCard::Delimiter::END_LINE_TOKEN, jami::vCard::Delimiter::END_TOKEN, jami::EUNAUTHORIZED, jami::vCard::Property::FORMATTED_NAME, infos(), JAMI_ERROR, jami::vCard::Property::PHOTO, jami::vCard::Property::RDV_ACCOUNT, jami::vCard::Value::RDV_ACCOUNT, jami::vCard::Property::RDV_DEVICE, jami::vCard::Value::RDV_DEVICE, jami::vCard::Delimiter::SEPARATOR_TOKEN, jami::vCard::Value::TITLE, jami::json::toString(), and jami::vCard::Property::VCARD_VERSION.

| std::string jami::ConversationRepository::uriFromDevice | ( | const std::string & | deviceId | ) | const |
Retrieve the uri from a deviceId.
| deviceId |
Definition at line 4205 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::checkEdit(), jami::ConversationRepository::Impl::checkInitialCommit(), jami::ConversationRepository::Impl::checkValidAdd(), jami::ConversationRepository::Impl::checkValidProfileUpdate(), jami::ConversationRepository::Impl::checkValidUserDiff(), jami::ConversationRepository::Impl::checkValidVoteResolution(), jami::ConversationRepository::Impl::checkVote(), jami::ConversationRepository::Impl::convCommitToMap(), and jami::ConversationRepository::Impl::log().
| std::pair< std::vector< ConversationCommit >, bool > jami::ConversationRepository::validClone | ( | ) | const |
Validate a clone.
Definition at line 4109 of file conversationrepository.cpp.
References jami::emitSignal(), and log().

| bool jami::ConversationRepository::validCommits | ( | const std::vector< ConversationCommit > & | commitsToValidate | ) | const |
Validate that commits are not malformed.
| commitsToValidate | the list of commits |
Definition at line 4127 of file conversationrepository.cpp.
References jami::emitSignal().

| std::pair< std::vector< ConversationCommit >, bool > jami::ConversationRepository::validFetch | ( | const std::string & | remoteDevice | ) | const |
Validate a fetch with remote device.
| remotedevice |
Definition at line 4095 of file conversationrepository.cpp.
References jami::emitSignal(), and remoteHead().
Referenced by mergeHistory().

| std::string jami::ConversationRepository::voteKick | ( | const std::string & | uri, |
| const std::string & | type | ||
| ) |
The voting system is divided in two parts.
The voting phase where admins can decide an action (such as kicking someone) and the resolving phase, when > 50% of the admins voted, we can considered the vote as finished Add a vote to kick a device or a user
| uri | identified of the user/device |
| type | device, members, admins or invited |
Definition at line 3851 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::getFullPath(), JAMI_ERROR, JAMI_WARNING, and jami::json::toString().

| std::string jami::ConversationRepository::voteUnban | ( | const std::string & | uri, |
| const std::string_view | type | ||
| ) |
Add a vote to re-add a user.
| uri | identified of the user |
| type | device, members, admins or invited |
Definition at line 3900 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::getFullPath(), JAMI_ERROR, and jami::json::toString().
