Move mapping function from FollowSetFeedFilter to FollowSet.

This commit is contained in:
KotlinGeekDev
2024-10-30 14:48:58 +01:00
parent bc7d9eef9b
commit 0b014c5c7c
2 changed files with 32 additions and 28 deletions
@@ -83,7 +83,38 @@ class PeopleListEvent(
val title: String,
val description: String?,
val profileList: Set<String>,
)
) {
companion object {
fun mapEventToSet(
event: PeopleListEvent,
signer: NostrSigner,
): FollowSet {
val dTag = event.dTag()
val listTitle = event.title() ?: dTag
val listDescription = event.description() ?: ""
val publicFollows = event.filterTagList("p", null)
val privateFollows = mutableListOf<String>()
event.privateTaggedUsers(signer) { userList -> privateFollows.addAll(userList) }
return if (publicFollows.isEmpty() && privateFollows.isNotEmpty()) {
FollowSet(
isPrivate = true,
title = listTitle,
description = listDescription,
profileList = privateFollows.toSet(),
)
} else if (publicFollows.isNotEmpty() && privateFollows.isEmpty()) {
FollowSet(
isPrivate = false,
title = listTitle,
description = listDescription,
profileList = publicFollows.toSet(),
)
} else {
throw Exception("Mixed follow sets are not yet supported.")
}
}
}
}
@Immutable
class UsersAndWords(