Ring Daemon
Loading...
Searching...
No Matches
jami::ConversationRepository::Impl Class Reference
Collaboration diagram for jami::ConversationRepository::Impl:
Collaboration graph

Public Member Functions

bool add (const std::string &path)
 
void addUserDevice ()
 
std::vector< ConversationCommitbehind (const std::string &from) const
 
bool checkEdit (const std::string &userDevice, const ConversationCommit &commit) const
 
bool checkInitialCommit (const std::string &userDevice, const std::string &commitId, const std::string &commitMsg) const
 
void checkLocks ()
 
bool checkValidAdd (const std::string &userDevice, const std::string &uriMember, const std::string &commitid, const std::string &parentId) const
 
bool checkValidJoins (const std::string &userDevice, const std::string &uriMember, const std::string &commitid, const std::string &parentId) const
 
bool checkValidMergeCommit (const std::string &mergeId, const std::vector< std::string > &parents) const
 Validate the merge commit by ensuring the absence of invalid files.
 
bool checkValidProfileUpdate (const std::string &userDevice, const std::string &commitid, const std::string &parentId) const
 
bool checkValidRemove (const std::string &userDevice, const std::string &uriMember, const std::string &commitid, const std::string &parentId) const
 
bool checkValidUserDiff (const std::string &userDevice, const std::string &commitId, const std::string &parentId) const
 
bool checkValidVoteResolution (const std::string &userDevice, const std::string &uriMember, const std::string &commitId, const std::string &parentId, const std::string &voteType) const
 
bool checkVote (const std::string &userDevice, const std::string &commitId, const std::string &parentId) const
 
std::string commit (const std::string &msg, bool verifyDevice=true)
 
std::string commitMessage (const std::string &msg, bool verifyDevice=true)
 
std::optional< std::map< std::string, std::string > > convCommitToMap (const ConversationCommit &commit) const
 
std::string createMergeCommit (git_index *index, const std::string &wanted_ref)
 
std::map< std::string, std::vector< DeviceId > > devices (bool ignoreExpired=true) const
 
GitDiff diff (git_repository *repo, const std::string &idNew, const std::string &idOld) const
 
std::string diffStats (const GitDiff &diff) const
 
std::string diffStats (const std::string &newId, const std::string &oldId) const
 
GitObject fileAtTree (const std::string &path, const GitTree &tree) const
 
void forEachCommit (PreConditionCb &&preCondition, std::function< void(ConversationCommit &&)> &&emplaceCb, PostConditionCb &&postCondition, const std::string &from="", bool logIfNotFound=true) const
 
std::optional< ConversationCommitgetCommit (const std::string &commitId) const
 
std::optional< std::set< std::string_view > > getDeltaPathsFromDiff (const GitDiff &diff) const
 Get the deltas from a git diff.
 
std::string getDisplayName () const
 
std::vector< std::string > getInitialMembers () const
 
bool hasCommit (const std::string &commitId) const
 
 Impl (const std::shared_ptr< JamiAccount > &account, const std::string &id)
 
void initMembers ()
 
bool isValidUserAtCommit (const std::string &userDevice, const std::string &commitId, const git_buf &sig, const git_buf &sig_data) const
 
void loadMembers ()
 
std::vector< ConversationCommitlog (const LogOptions &options) const
 
GitObject memberCertificate (std::string_view memberUri, const GitTree &tree) const
 
std::vector< ConversationMembermembers () const
 
std::set< std::string > memberUris (std::string_view filter, const std::set< MemberRole > &filteredRoles) const
 
bool mergeFastforward (const git_oid *target_oid, int is_unborn)
 
ConversationMode mode () const
 
ConversationCommit parseCommit (git_repository *repo, const git_commit *commit) const
 
GitRepository repository () const
 
void resetHard ()
 
bool resolveBan (const std::string_view type, const std::string &uri)
 
bool resolveConflicts (git_index *index, const std::string &other_id)
 
bool resolveUnban (const std::string_view type, const std::string &uri)
 
void saveMembers ()
 
GitSignature signature ()
 
GitTree treeAtCommit (git_repository *repo, const std::string &commitId) const
 
std::string uriFromDevice (const std::string &deviceId, const std::string &commitId="") const
 Retrieve the user related to a device using the account's certificate store.
 
std::string uriFromDeviceAtCommit (const std::string &deviceId, const std::string &commitId) const
 Retrieve the user related to a device using certificate directly from the repository at a specific commit.
 
bool validateDevice ()
 
bool validCommits (const std::vector< ConversationCommit > &commits) const
 
bool verifyCertificate (std::string_view certContent, const std::string &userUri, std::string_view oldCert=""sv) const
 Verify that a certificate modification is correct.
 

Public Attributes

std::weak_ptr< JamiAccountaccount_
 
const std::string accountId_
 
std::filesystem::path conversationDataPath_ {}
 
const std::string deviceId_
 
std::map< std::string, std::string > deviceToUri_
 
std::mutex deviceToUriMtx_
 
const std::string id_
 
std::vector< ConversationMembermembers_ {}
 
std::filesystem::path membersCache_ {}
 
std::mutex membersMtx_ {}
 
std::optional< ConversationModemode_ {}
 
OnMembersChanged onMembersChanged_ {}
 
std::mutex opMtx_
 
MemberRole updateProfilePermLvl_ {MemberRole::ADMIN}
 
const std::string userId_
 

Detailed Description

Definition at line 83 of file conversationrepository.cpp.

Constructor & Destructor Documentation

◆ Impl()

jami::ConversationRepository::Impl::Impl ( const std::shared_ptr< JamiAccount > &  account,
const std::string &  id 
)
inline

Definition at line 86 of file conversationrepository.cpp.

References accountId_, checkLocks(), conversationDataPath_, jami::fileutils::get_data_dir(), id_, initMembers(), loadMembers(), members_, and membersCache_.

Here is the call graph for this function:

Member Function Documentation

◆ add()

bool jami::ConversationRepository::Impl::add ( const std::string &  path)

Definition at line 1035 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Referenced by addUserDevice().

Here is the call graph for this function:

◆ addUserDevice()

void jami::ConversationRepository::Impl::addUserDevice ( )

Definition at line 3428 of file conversationrepository.cpp.

References account_, add(), deviceId_, jami::emitSignal(), JAMI_ERROR, JAMI_WARNING, and repository().

Here is the call graph for this function:

◆ behind()

std::vector< ConversationCommit > jami::ConversationRepository::Impl::behind ( const std::string &  from) const

Definition at line 2281 of file conversationrepository.cpp.

References jami::emitSignal(), JAMI_ERROR, and jami::ConversationRepository::log().

Here is the call graph for this function:

◆ checkEdit()

bool jami::ConversationRepository::Impl::checkEdit ( const std::string &  userDevice,
const ConversationCommit commit 
) const

◆ checkInitialCommit()

bool jami::ConversationRepository::Impl::checkInitialCommit ( const std::string &  userDevice,
const std::string &  commitId,
const std::string &  commitMsg 
) const

◆ checkLocks()

void jami::ConversationRepository::Impl::checkLocks ( )
inline

Definition at line 102 of file conversationrepository.cpp.

References accountId_, jami::emitSignal(), id_, JAMI_ERROR, JAMI_WARNING, and repository().

Referenced by Impl().

Here is the call graph for this function:

◆ checkValidAdd()

bool jami::ConversationRepository::Impl::checkValidAdd ( const std::string &  userDevice,
const std::string &  uriMember,
const std::string &  commitid,
const std::string &  parentId 
) const

◆ checkValidJoins()

bool jami::ConversationRepository::Impl::checkValidJoins ( const std::string &  userDevice,
const std::string &  uriMember,
const std::string &  commitid,
const std::string &  parentId 
) const

◆ checkValidMergeCommit()

bool jami::ConversationRepository::Impl::checkValidMergeCommit ( const std::string &  mergeId,
const std::vector< std::string > &  parents 
) const

Validate the merge commit by ensuring the absence of invalid files.

Parameters
mergeIdThe id of the merge commit
parentsThe two commit IDs of parent's of the merge commit
Returns
bool Whether or not invalid files were found in the merge commit

Definition at line 1707 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

◆ checkValidProfileUpdate()

bool jami::ConversationRepository::Impl::checkValidProfileUpdate ( const std::string &  userDevice,
const std::string &  commitid,
const std::string &  parentId 
) const

◆ checkValidRemove()

bool jami::ConversationRepository::Impl::checkValidRemove ( const std::string &  userDevice,
const std::string &  uriMember,
const std::string &  commitid,
const std::string &  parentId 
) const

◆ checkValidUserDiff()

bool jami::ConversationRepository::Impl::checkValidUserDiff ( const std::string &  userDevice,
const std::string &  commitId,
const std::string &  parentId 
) const

◆ checkValidVoteResolution()

bool jami::ConversationRepository::Impl::checkValidVoteResolution ( const std::string &  userDevice,
const std::string &  uriMember,
const std::string &  commitId,
const std::string &  parentId,
const std::string &  voteType 
) const

◆ checkVote()

bool jami::ConversationRepository::Impl::checkVote ( const std::string &  userDevice,
const std::string &  commitId,
const std::string &  parentId 
) const

◆ commit()

std::string jami::ConversationRepository::Impl::commit ( const std::string &  msg,
bool  verifyDevice = true 
)

Definition at line 2051 of file conversationrepository.cpp.

References jami::ECOMMIT, jami::emitSignal(), jami::base64::encode(), JAMI_ERROR, and JAMI_LOG.

Referenced by getCommit().

Here is the call graph for this function:

◆ commitMessage()

std::string jami::ConversationRepository::Impl::commitMessage ( const std::string &  msg,
bool  verifyDevice = true 
)

Definition at line 3486 of file conversationrepository.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ convCommitToMap()

◆ createMergeCommit()

std::string jami::ConversationRepository::Impl::createMergeCommit ( git_index index,
const std::string &  wanted_ref 
)

Definition at line 806 of file conversationrepository.cpp.

References jami::ECOMMIT, jami::emitSignal(), jami::base64::encode(), JAMI_ERROR, and JAMI_LOG.

Here is the call graph for this function:

◆ devices()

std::map< std::string, std::vector< DeviceId > > jami::ConversationRepository::Impl::devices ( bool  ignoreExpired = true) const
inline

Definition at line 314 of file conversationrepository.cpp.

References account_, jami::emitSignal(), jami::fileutils::loadFile(), and repository().

Here is the call graph for this function:

◆ diff()

GitDiff jami::ConversationRepository::Impl::diff ( git_repository repo,
const std::string &  idNew,
const std::string &  idOld 
) const

Definition at line 2212 of file conversationrepository.cpp.

References jami::emitSignal(), JAMI_ERROR, and JAMI_WARNING.

Here is the call graph for this function:

◆ diffStats() [1/2]

std::string jami::ConversationRepository::Impl::diffStats ( const GitDiff diff) const

Definition at line 2660 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

◆ diffStats() [2/2]

std::string jami::ConversationRepository::Impl::diffStats ( const std::string &  newId,
const std::string &  oldId 
) const

Definition at line 2202 of file conversationrepository.cpp.

References jami::ConversationRepository::diffStats(), and jami::emitSignal().

Here is the call graph for this function:

◆ fileAtTree()

GitObject jami::ConversationRepository::Impl::fileAtTree ( const std::string &  path,
const GitTree tree 
) const

Definition at line 2432 of file conversationrepository.cpp.

References jami::emitSignal().

Referenced by uriFromDeviceAtCommit().

Here is the call graph for this function:

◆ forEachCommit()

void jami::ConversationRepository::Impl::forEachCommit ( PreConditionCb &&  preCondition,
std::function< void(ConversationCommit &&)> &&  emplaceCb,
PostConditionCb &&  postCondition,
const std::string &  from = "",
bool  logIfNotFound = true 
) const

Definition at line 2318 of file conversationrepository.cpp.

References jami::ConversationCommit::author, jami::Break, jami::emitSignal(), JAMI_DEBUG, JAMI_ERROR, JAMI_WARNING, and jami::Skip.

Here is the call graph for this function:

◆ getCommit()

std::optional< ConversationCommit > jami::ConversationRepository::Impl::getCommit ( const std::string &  commitId) const
inline

Definition at line 371 of file conversationrepository.cpp.

References commit(), jami::emitSignal(), parseCommit(), and repository().

Here is the call graph for this function:

◆ getDeltaPathsFromDiff()

std::optional< std::set< std::string_view > > jami::ConversationRepository::Impl::getDeltaPathsFromDiff ( const GitDiff diff) const

Get the deltas from a git diff.

Parameters
diffThe diff object to extract deltas from
Returns
The set of git_diff deltas extracted from the diff

Definition at line 1684 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_LOG.

Here is the call graph for this function:

◆ getDisplayName()

std::string jami::ConversationRepository::Impl::getDisplayName ( ) const
inline

Definition at line 211 of file conversationrepository.cpp.

References account_, deviceId_, and jami::regex_display_name().

Referenced by signature().

Here is the call graph for this function:

◆ getInitialMembers()

std::vector< std::string > jami::ConversationRepository::Impl::getInitialMembers ( ) const

◆ hasCommit()

bool jami::ConversationRepository::Impl::hasCommit ( const std::string &  commitId) const
inline

Definition at line 353 of file conversationrepository.cpp.

References jami::emitSignal(), and repository().

Here is the call graph for this function:

◆ initMembers()

◆ isValidUserAtCommit()

bool jami::ConversationRepository::Impl::isValidUserAtCommit ( const std::string &  userDevice,
const std::string &  commitId,
const git_buf sig,
const git_buf sig_data 
) const

Definition at line 1791 of file conversationrepository.cpp.

References jami::as_view(), jami::base64::decode(), jami::emitSignal(), JAMI_ERROR, and JAMI_WARNING.

Here is the call graph for this function:

◆ loadMembers()

void jami::ConversationRepository::Impl::loadMembers ( )
inline

Definition at line 168 of file conversationrepository.cpp.

References jami::emitSignal(), jami::fileutils::loadFile(), members_, membersCache_, and membersMtx_.

Referenced by Impl().

Here is the call graph for this function:

◆ log()

std::vector< ConversationCommit > jami::ConversationRepository::Impl::log ( const LogOptions options) const

Definition at line 2381 of file conversationrepository.cpp.

References jami::Break, jami::emitSignal(), jami::Ok, jami::Skip, and jami::ConversationRepository::uriFromDevice().

Here is the call graph for this function:

◆ memberCertificate()

GitObject jami::ConversationRepository::Impl::memberCertificate ( std::string_view  memberUri,
const GitTree tree 
) const

Definition at line 2443 of file conversationrepository.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ members()

std::vector< ConversationMember > jami::ConversationRepository::Impl::members ( ) const
inline

Definition at line 305 of file conversationrepository.cpp.

References jami::emitSignal(), members_, and membersMtx_.

Here is the call graph for this function:

◆ memberUris()

std::set< std::string > jami::ConversationRepository::Impl::memberUris ( std::string_view  filter,
const std::set< MemberRole > &  filteredRoles 
) const
inline

Definition at line 391 of file conversationrepository.cpp.

References jami::emitSignal(), members_, and membersMtx_.

Referenced by saveMembers().

Here is the call graph for this function:

◆ mergeFastforward()

bool jami::ConversationRepository::Impl::mergeFastforward ( const git_oid target_oid,
int  is_unborn 
)

Definition at line 956 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

◆ mode()

◆ parseCommit()

ConversationCommit jami::ConversationRepository::Impl::parseCommit ( git_repository repo,
const git_commit commit 
) const

Definition at line 2682 of file conversationrepository.cpp.

References jami::base64::decode(), jami::GitAuthor::email, jami::emitSignal(), jami::ConversationCommit::id, JAMI_WARNING, and jami::GitAuthor::name.

Referenced by getCommit().

Here is the call graph for this function:

◆ repository()

GitRepository jami::ConversationRepository::Impl::repository ( ) const
inline

◆ resetHard()

void jami::ConversationRepository::Impl::resetHard ( )

Definition at line 3458 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

◆ resolveBan()

bool jami::ConversationRepository::Impl::resolveBan ( const std::string_view  type,
const std::string &  uri 
)

Definition at line 3939 of file conversationrepository.cpp.

References jami::BANNED, jami::emitSignal(), JAMI_ERROR, and jami::fileutils::loadFile().

Here is the call graph for this function:

◆ resolveConflicts()

bool jami::ConversationRepository::Impl::resolveConflicts ( git_index index,
const std::string &  other_id 
)

Definition at line 2498 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

◆ resolveUnban()

bool jami::ConversationRepository::Impl::resolveUnban ( const std::string_view  type,
const std::string &  uri 
)

Definition at line 3998 of file conversationrepository.cpp.

References jami::ADMIN, jami::emitSignal(), jami::INVITED, JAMI_ERROR, and jami::MEMBER.

Here is the call graph for this function:

◆ saveMembers()

void jami::ConversationRepository::Impl::saveMembers ( )
inline

Definition at line 181 of file conversationrepository.cpp.

References jami::emitSignal(), members_, membersCache_, memberUris(), and onMembersChanged_.

Here is the call graph for this function:

◆ signature()

GitSignature jami::ConversationRepository::Impl::signature ( )

Definition at line 784 of file conversationrepository.cpp.

References accountId_, deviceId_, jami::emitSignal(), getDisplayName(), id_, and JAMI_ERROR.

Here is the call graph for this function:

◆ treeAtCommit()

GitTree jami::ConversationRepository::Impl::treeAtCommit ( git_repository repo,
const std::string &  commitId 
) const

Definition at line 2452 of file conversationrepository.cpp.

References jami::emitSignal(), JAMI_ERROR, and JAMI_WARNING.

Referenced by uriFromDeviceAtCommit().

Here is the call graph for this function:

◆ uriFromDevice()

std::string jami::ConversationRepository::Impl::uriFromDevice ( const std::string &  deviceId,
const std::string &  commitId = "" 
) const
inline

Retrieve the user related to a device using the account's certificate store.

Note
deviceToUri_ is used to cache result and avoid always loading the certificate

Definition at line 415 of file conversationrepository.cpp.

References account_, deviceToUri_, deviceToUriMtx_, jami::emitSignal(), JAMI_WARNING, jami::fileutils::loadFile(), repository(), and uriFromDeviceAtCommit().

Here is the call graph for this function:

◆ uriFromDeviceAtCommit()

std::string jami::ConversationRepository::Impl::uriFromDeviceAtCommit ( const std::string &  deviceId,
const std::string &  commitId 
) const
inline

Retrieve the user related to a device using certificate directly from the repository at a specific commit.

Note
Prefer uriFromDevice() if possible as it uses the cache.

Definition at line 467 of file conversationrepository.cpp.

References jami::as_view(), jami::emitSignal(), fileAtTree(), JAMI_ERROR, repository(), and treeAtCommit().

Referenced by uriFromDevice().

Here is the call graph for this function:

◆ validateDevice()

bool jami::ConversationRepository::Impl::validateDevice ( )

Definition at line 1955 of file conversationrepository.cpp.

References jami::emitSignal(), JAMI_ERROR, JAMI_WARNING, and jami::fileutils::loadFile().

Here is the call graph for this function:

◆ validCommits()

bool jami::ConversationRepository::Impl::validCommits ( const std::vector< ConversationCommit > &  commits) const

◆ verifyCertificate()

bool jami::ConversationRepository::Impl::verifyCertificate ( std::string_view  certContent,
const std::string &  userUri,
std::string_view  oldCert = ""sv 
) const
inline

Verify that a certificate modification is correct.

Parameters
certPathWhere the certificate is saved (relative path)
userUriAccount we want for this certificate
oldCertPrevious certificate. getId() should return the same id as the new certificate.
Note
There is a few exception because JAMS certificates are buggy right now

Definition at line 491 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

Member Data Documentation

◆ account_

std::weak_ptr<JamiAccount> jami::ConversationRepository::Impl::account_

Definition at line 294 of file conversationrepository.cpp.

Referenced by addUserDevice(), devices(), getDisplayName(), and uriFromDevice().

◆ accountId_

const std::string jami::ConversationRepository::Impl::accountId_

Definition at line 296 of file conversationrepository.cpp.

Referenced by checkLocks(), Impl(), repository(), and signature().

◆ conversationDataPath_

std::filesystem::path jami::ConversationRepository::Impl::conversationDataPath_ {}

Definition at line 311 of file conversationrepository.cpp.

Referenced by Impl().

◆ deviceId_

const std::string jami::ConversationRepository::Impl::deviceId_

Definition at line 298 of file conversationrepository.cpp.

Referenced by addUserDevice(), getDisplayName(), and signature().

◆ deviceToUri_

std::map<std::string, std::string> jami::ConversationRepository::Impl::deviceToUri_
mutable

Definition at line 460 of file conversationrepository.cpp.

Referenced by uriFromDevice().

◆ deviceToUriMtx_

std::mutex jami::ConversationRepository::Impl::deviceToUriMtx_
mutable

Definition at line 459 of file conversationrepository.cpp.

Referenced by uriFromDevice().

◆ id_

const std::string jami::ConversationRepository::Impl::id_

Definition at line 295 of file conversationrepository.cpp.

Referenced by checkLocks(), Impl(), repository(), and signature().

◆ members_

std::vector<ConversationMember> jami::ConversationRepository::Impl::members_ {}

Definition at line 303 of file conversationrepository.cpp.

Referenced by Impl(), loadMembers(), members(), memberUris(), and saveMembers().

◆ membersCache_

std::filesystem::path jami::ConversationRepository::Impl::membersCache_ {}

Definition at line 312 of file conversationrepository.cpp.

Referenced by Impl(), loadMembers(), and saveMembers().

◆ membersMtx_

std::mutex jami::ConversationRepository::Impl::membersMtx_ {}
mutable

Definition at line 302 of file conversationrepository.cpp.

Referenced by loadMembers(), members(), and memberUris().

◆ mode_

std::optional<ConversationMode> jami::ConversationRepository::Impl::mode_ {}
mutable

Definition at line 299 of file conversationrepository.cpp.

◆ onMembersChanged_

OnMembersChanged jami::ConversationRepository::Impl::onMembersChanged_ {}

Definition at line 195 of file conversationrepository.cpp.

Referenced by saveMembers().

◆ opMtx_

std::mutex jami::ConversationRepository::Impl::opMtx_

Definition at line 541 of file conversationrepository.cpp.

◆ updateProfilePermLvl_

MemberRole jami::ConversationRepository::Impl::updateProfilePermLvl_ {MemberRole::ADMIN}

Definition at line 409 of file conversationrepository.cpp.

◆ userId_

const std::string jami::ConversationRepository::Impl::userId_

Definition at line 297 of file conversationrepository.cpp.


The documentation for this class was generated from the following file: