Ring Daemon 16.0.0
|
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, bool logIfNotFound=true) const |
std::string | getHead () const |
Get current HEAD hash. | |
std::vector< std::string > | getInitialMembers () const |
One to one util, get initial members. | |
const std::string & | id () const |
Return the conversation id. | |
std::map< std::string, std::string > | infos () const |
Retrieve current infos (title, description, avatar, mode) | |
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::string | mergeBase (const std::string &from, const std::string &to) const |
Get the common parent between two branches. | |
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. | |
bool | validClone (std::function< void(std::vector< ConversationCommit >)> &&checkCommitCb) const |
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::unique_ptr< ConversationRepository > | cloneConversation (const std::shared_ptr< JamiAccount > &account, const std::string &deviceId, const std::string &conversationId, std::function< void(std::vector< ConversationCommit >)> &&checkCommitCb={}) |
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 (std::map< std::string, std::string > &&details) |
This class gives access to the git repository that represents the conversation.
Definition at line 141 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 2888 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 2902 of file conversationrepository.cpp.
References jami::emitSignal(), jami::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 2953 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 3342 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 |
checkCommitCb | Used if commits should be treated |
Definition at line 2632 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::get_data_dir(), JAMI_DEBUG, JAMI_ERROR, JAMI_LOG, JAMI_WARNING, and MAX_FETCH_SIZE.
Referenced by jami::Conversation::Impl::Impl().
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 3149 of file conversationrepository.cpp.
References jami::emitSignal().
std::vector< std::string > jami::ConversationRepository::commitMessages | ( | const std::vector< std::string > & | msgs | ) |
Definition at line 3164 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 4008 of file conversationrepository.cpp.
References jami::emitSignal().
std::optional< std::map< std::string, std::string > > jami::ConversationRepository::convCommitToMap | ( | const ConversationCommit & | commit | ) | const |
Definition at line 4002 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 2579 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 3818 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 3336 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 3498 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 3004 of file conversationrepository.cpp.
References jami::emitSignal(), JAMI_ERROR, JAMI_WARNING, log(), MAX_FETCH_SIZE, and jami::LogOptions::nbOfCommits.
std::optional< ConversationCommit > jami::ConversationRepository::getCommit | ( | const std::string & | commitId, |
bool | logIfNotFound = true |
||
) | const |
Definition at line 3195 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by jami::ConversationRepository::Impl::checkEdit().
std::string jami::ConversationRepository::getHead | ( | ) | const |
Get current HEAD hash.
Definition at line 3987 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 3799 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::checkValidAdd(), and jami::ConversationRepository::Impl::initMembers().
const std::string & jami::ConversationRepository::id | ( | ) | const |
Return the conversation id.
Definition at line 2896 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::convCommitToMap(), createConversation(), and jami::ConversationRepository::Impl::forEachCommit().
std::map< std::string, std::string > jami::ConversationRepository::infos | ( | ) | const |
Retrieve current infos (title, description, avatar, mode)
Definition at line 3945 of file conversationrepository.cpp.
References jami::emitSignal(), infosFromVCard(), jami::fileutils::loadFile(), mode(), and vCard::utils::toMap().
Referenced by updateInfos().
|
static |
Definition at line 3967 of file conversationrepository.cpp.
References vCard::Property::DESCRIPTION, jami::emitSignal(), vCard::Property::FORMATTED_NAME, vCard::Property::PHOTO, vCard::Property::RDV_ACCOUNT, and vCard::Property::RDV_DEVICE.
Referenced by infos(), and jami::ConversationModule::onTrustRequest().
std::string jami::ConversationRepository::join | ( | ) |
Join a repository.
Definition at line 3357 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::getFullPath(), jami::git_add_all(), JAMI_ERROR, jami::MEMBER, and jami::json::toString().
std::string jami::ConversationRepository::leave | ( | ) |
Erase self from repository.
Definition at line 3428 of file conversationrepository.cpp.
References jami::emitSignal(), jami::git_add_all(), jami::fileutils::loadFile(), 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 3175 of file conversationrepository.cpp.
References jami::emitSignal().
Referenced by jami::ConversationRepository::Impl::behind(), fetch(), jami::ConversationRepository::Impl::getInitialMembers(), jami::ConversationRepository::Impl::mode(), 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 3181 of file conversationrepository.cpp.
References jami::emitSignal().
std::vector< ConversationMember > jami::ConversationRepository::members | ( | ) | const |
Get conversation's members.
Definition at line 3805 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 3811 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 3201 of file conversationrepository.cpp.
References jami::emitSignal(), jami::git_add_all(), JAMI_ERROR, and JAMI_LOG.
std::string jami::ConversationRepository::mergeBase | ( | const std::string & | from, |
const std::string & | to | ||
) | const |
Get the common parent between two branches.
from | The first branch |
to | The second branch |
Definition at line 3322 of file conversationrepository.cpp.
References jami::emitSignal().
ConversationMode jami::ConversationRepository::mode | ( | ) | const |
Get conversation's mode.
Definition at line 3509 of file conversationrepository.cpp.
Referenced by jami::ConversationRepository::Impl::checkInitialCommit(), jami::ConversationRepository::Impl::checkValidAdd(), createConversation(), jami::ConversationRepository::Impl::getInitialMembers(), infos(), jami::ConversationRepository::Impl::initMembers(), and jami::ConversationRepository::Impl::mode().
void jami::ConversationRepository::onMembersChanged | ( | OnMembersChanged && | cb | ) |
Definition at line 2947 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 3833 of file conversationrepository.cpp.
References jami::emitSignal().
void jami::ConversationRepository::refreshMembers | ( | ) | const |
To use after a merge with member's events, refresh members knowledge.
Definition at line 3824 of file conversationrepository.cpp.
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 3070 of file conversationrepository.cpp.
References jami::emitSignal(), JAMI_ERROR, JAMI_WARNING, and remoteHead().
Referenced by remoteHead(), and validFetch().
Delete branch with remote.
remoteDevice |
Definition at line 3785 of file conversationrepository.cpp.
References jami::emitSignal(), and JAMI_WARNING.
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 3702 of file conversationrepository.cpp.
References 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 3864 of file conversationrepository.cpp.
References vCard::Value::AVATAR, vCard::Property::BASE64, vCard::Delimiter::BEGIN_TOKEN, vCard::Property::DESCRIPTION, vCard::Value::DESCRIPTION, jami::emitSignal(), vCard::Delimiter::END_LINE_TOKEN, vCard::Delimiter::END_TOKEN, jami::EUNAUTHORIZED, vCard::Property::FORMATTED_NAME, infos(), JAMI_ERROR, vCard::Property::PHOTO, vCard::Property::RDV_ACCOUNT, vCard::Value::RDV_ACCOUNT, vCard::Property::RDV_DEVICE, vCard::Value::RDV_DEVICE, vCard::Delimiter::SEPARATOR_TOKEN, vCard::Value::TITLE, jami::json::toString(), and vCard::Property::VCARD_VERSION.
std::string jami::ConversationRepository::uriFromDevice | ( | const std::string & | deviceId | ) | const |
Retrieve the uri from a deviceId.
deviceId |
Definition at line 3858 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().
bool jami::ConversationRepository::validClone | ( | std::function< void(std::vector< ConversationCommit >)> && | checkCommitCb | ) | const |
Definition at line 3772 of file conversationrepository.cpp.
References jami::emitSignal(), and log().
std::pair< std::vector< ConversationCommit >, bool > jami::ConversationRepository::validFetch | ( | const std::string & | remoteDevice | ) | const |
Validate a fetch with remote device.
remotedevice |
Definition at line 3758 of file conversationrepository.cpp.
References jami::emitSignal(), and remoteHead().
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 3515 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 3564 of file conversationrepository.cpp.
References jami::emitSignal(), jami::fileutils::getFullPath(), JAMI_ERROR, and jami::json::toString().