Adds methods to follow a bunch of users at the same time
This commit is contained in:
@@ -935,6 +935,8 @@ class Account(
|
|||||||
|
|
||||||
fun upgradeAttestations() = otsState.upgradeAttestationsIfNeeded(::sendAutomatic)
|
fun upgradeAttestations() = otsState.upgradeAttestationsIfNeeded(::sendAutomatic)
|
||||||
|
|
||||||
|
suspend fun follow(users: List<User>) = sendMyPublicAndPrivateOutbox(kind3FollowList.follow(users))
|
||||||
|
|
||||||
suspend fun follow(user: User) = sendMyPublicAndPrivateOutbox(kind3FollowList.follow(user))
|
suspend fun follow(user: User) = sendMyPublicAndPrivateOutbox(kind3FollowList.follow(user))
|
||||||
|
|
||||||
suspend fun unfollow(user: User) = sendMyPublicAndPrivateOutbox(kind3FollowList.unfollow(user))
|
suspend fun unfollow(user: User) = sendMyPublicAndPrivateOutbox(kind3FollowList.unfollow(user))
|
||||||
|
|||||||
+19
@@ -113,6 +113,25 @@ class Kind3FollowListState(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun follow(users: List<User>): ContactListEvent {
|
||||||
|
val contactList = getFollowListEvent()
|
||||||
|
|
||||||
|
val contacts =
|
||||||
|
users.map {
|
||||||
|
ContactTag(user.pubkeyHex, user.bestRelayHint(), null)
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (contactList != null) {
|
||||||
|
ContactListEvent.followUsers(contactList, contacts, signer)
|
||||||
|
} else {
|
||||||
|
ContactListEvent.createFromScratch(
|
||||||
|
followUsers = contacts,
|
||||||
|
relayUse = emptyMap(),
|
||||||
|
signer = signer,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun follow(user: User): ContactListEvent {
|
suspend fun follow(user: User): ContactListEvent {
|
||||||
val contactList = getFollowListEvent()
|
val contactList = getFollowListEvent()
|
||||||
|
|
||||||
|
|||||||
+2
@@ -914,6 +914,8 @@ class AccountViewModel(
|
|||||||
|
|
||||||
fun unfollow(channel: EphemeralChatChannel) = launchSigner { account.unfollow(channel) }
|
fun unfollow(channel: EphemeralChatChannel) = launchSigner { account.unfollow(channel) }
|
||||||
|
|
||||||
|
fun follow(users: List<User>) = launchSigner { account.follow(users) }
|
||||||
|
|
||||||
fun follow(user: User) = launchSigner { account.follow(user) }
|
fun follow(user: User) = launchSigner { account.follow(user) }
|
||||||
|
|
||||||
fun unfollow(user: User) = launchSigner { account.unfollow(user) }
|
fun unfollow(user: User) = launchSigner { account.unfollow(user) }
|
||||||
|
|||||||
+19
@@ -123,6 +123,25 @@ class ContactListEvent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun followUsers(
|
||||||
|
earlierVersion: ContactListEvent,
|
||||||
|
users: List<ContactTag>,
|
||||||
|
signer: NostrSigner,
|
||||||
|
createdAt: Long = TimeUtils.now(),
|
||||||
|
): ContactListEvent {
|
||||||
|
val follows = earlierVersion.verifiedFollowKeySet()
|
||||||
|
val toBeAdded = users.filter { it.pubKey !in follows }.distinctBy { it.pubKey }.map { it.toTagArray() }
|
||||||
|
|
||||||
|
if (toBeAdded.isEmpty()) return earlierVersion
|
||||||
|
|
||||||
|
return create(
|
||||||
|
content = earlierVersion.content,
|
||||||
|
tags = earlierVersion.tags + toBeAdded,
|
||||||
|
signer = signer,
|
||||||
|
createdAt = createdAt,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun unfollowUser(
|
suspend fun unfollowUser(
|
||||||
earlierVersion: ContactListEvent,
|
earlierVersion: ContactListEvent,
|
||||||
pubKeyHex: String,
|
pubKeyHex: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user