getMemberProfileModel static method
Future<MemberProfileModel>
getMemberProfileModel(
- bool create,
- AppModel app,
- String feedId,
- String memberId,
- String? photoURL,
- String name,
- MemberProfileAccessibleByGroup accessibleByGroup,
- List<String>? accessibleByMembers,
)
Implementation
static Future<MemberProfileModel> getMemberProfileModel(
bool create,
AppModel app,
String feedId,
String memberId,
String? photoURL,
String name,
MemberProfileAccessibleByGroup accessibleByGroup,
List<String>? accessibleByMembers) async {
var key = "$memberId-$feedId";
var memberProfileModel =
await memberProfileRepository(appId: app.documentID)!
.get(key, onError: (exception) {});
if (memberProfileModel == null) {
// create default profile
memberProfileModel = MemberProfileModel(
documentID: key,
appId: app.documentID,
feedId: feedId,
authorId: memberId,
accessibleByGroup: accessibleByGroup,
accessibleByMembers: accessibleByMembers,
profileOverride: photoURL,
nameOverride: name,
readAccess: [
memberId
], // default readAccess to the owner. The function will expand this based on accessibleByGroup/Members
);
if (create) {
await memberProfileRepository(appId: app.documentID)!
.add(memberProfileModel);
}
}
return memberProfileModel;
}