Ring Daemon 16.0.0
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 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, bool logIfNotFound=true) const
 
std::string getDisplayName () const
 
std::vector< std::string > getInitialMembers () 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
 
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
 
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 61 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 64 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 988 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 3099 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 2131 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 81 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

◆ 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 1875 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:

◆ commitMessage()

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

Definition at line 3157 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 763 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 268 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 2059 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 2555 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 2049 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 2315 of file conversationrepository.cpp.

References jami::emitSignal().

Referenced by uriFromDeviceAtCommit().

Here is the call graph for this function:

◆ forEachCommit()

◆ getCommit()

std::optional< ConversationCommit > jami::ConversationRepository::Impl::getCommit ( const std::string &  commitId,
bool  logIfNotFound = true 
) const
inline

Definition at line 316 of file conversationrepository.cpp.

References jami::emitSignal(), jami::LogOptions::from, and log().

Here is the call graph for this function:

◆ getDisplayName()

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

Definition at line 167 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

◆ initMembers()

void jami::ConversationRepository::Impl::initMembers ( )

◆ isValidUserAtCommit()

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

Definition at line 1636 of file conversationrepository.cpp.

References jami::as_view(), 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 123 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 2264 of file conversationrepository.cpp.

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

Referenced by getCommit().

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 2329 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 258 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 331 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 919 of file conversationrepository.cpp.

References jami::emitSignal(), and JAMI_ERROR.

Here is the call graph for this function:

◆ mode()

◆ repository()

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

Definition at line 154 of file conversationrepository.cpp.

References accountId_, jami::emitSignal(), jami::fileutils::get_data_dir(), id_, and JAMI_ERROR.

Referenced by addUserDevice(), checkLocks(), devices(), uriFromDevice(), and uriFromDeviceAtCommit().

Here is the call graph for this function:

◆ resetHard()

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

Definition at line 3129 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 3603 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 2388 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 3659 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 136 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 741 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 2339 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 357 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 409 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 1787 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

Definition at line 2700 of file conversationrepository.cpp.

References jami::emitSignal(), jami::EVALIDFETCH, JAMI_DEBUG, JAMI_ERROR, JAMI_WARNING, and jami::json::parse().

Here is the call graph for this function:

◆ 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 433 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 247 of file conversationrepository.cpp.

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

◆ accountId_

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

Definition at line 249 of file conversationrepository.cpp.

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

◆ conversationDataPath_

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

Definition at line 265 of file conversationrepository.cpp.

Referenced by Impl().

◆ deviceId_

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

Definition at line 251 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 402 of file conversationrepository.cpp.

Referenced by uriFromDevice().

◆ deviceToUriMtx_

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

Definition at line 401 of file conversationrepository.cpp.

Referenced by uriFromDevice().

◆ id_

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

Definition at line 248 of file conversationrepository.cpp.

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

◆ members_

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

Definition at line 256 of file conversationrepository.cpp.

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

◆ membersCache_

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

Definition at line 266 of file conversationrepository.cpp.

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

◆ membersMtx_

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

Definition at line 255 of file conversationrepository.cpp.

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

◆ mode_

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

Definition at line 252 of file conversationrepository.cpp.

◆ onMembersChanged_

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

Definition at line 150 of file conversationrepository.cpp.

Referenced by saveMembers().

◆ opMtx_

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

Definition at line 484 of file conversationrepository.cpp.

◆ updateProfilePermLvl_

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

Definition at line 351 of file conversationrepository.cpp.

◆ userId_

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

Definition at line 250 of file conversationrepository.cpp.


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