mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-09 04:18:11 +02:00
Avoids concurrent exceptions
This commit is contained in:
parent
a0ba313661
commit
e59dfa7a76
@ -373,13 +373,13 @@ class Account(
|
||||
|
||||
fun isAcceptable(user: User): Boolean {
|
||||
return user !in hiddenUsers() // if user hasn't hided this author
|
||||
&& user.reports.firstOrNull { it.author == userProfile() } == null // if user has not reported this post
|
||||
&& user.reports.filter { it.author in userProfile().follows }.size < 5
|
||||
&& user.reportsBy( userProfile() ).isEmpty() // if user has not reported this post
|
||||
&& user.reportsBy( userProfile().follows ).size < 5
|
||||
}
|
||||
|
||||
fun isAcceptableDirect(note: Note): Boolean {
|
||||
return note.reports.firstOrNull { it.author == userProfile() } == null // if user has not reported this post
|
||||
&& note.reports.filter { it.author in userProfile().follows }.size < 5 // if it has 5 reports by reliable users
|
||||
return note.reportsBy( userProfile() ).isEmpty() // if user has not reported this post
|
||||
&& note.reportsBy( userProfile().follows ).size < 5 // if it has 5 reports by reliable users
|
||||
}
|
||||
|
||||
fun isAcceptable(note: Note): Boolean {
|
||||
|
@ -107,6 +107,18 @@ class Note(val idHex: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun reportsBy(user: User): List<Note> {
|
||||
return synchronized(reports) {
|
||||
reports.filter { it.author == user }
|
||||
}
|
||||
}
|
||||
|
||||
fun reportsBy(users: Set<User>): List<Note> {
|
||||
return synchronized(reports) {
|
||||
reports.filter { it.author in users }
|
||||
}
|
||||
}
|
||||
|
||||
// Observers line up here.
|
||||
val live: NoteLiveData = NoteLiveData(this)
|
||||
|
||||
|
@ -93,6 +93,18 @@ class User(val pubkey: ByteArray) {
|
||||
}
|
||||
}
|
||||
|
||||
fun reportsBy(user: User): List<Note> {
|
||||
return synchronized(reports) {
|
||||
reports.filter { it.author == user }
|
||||
}
|
||||
}
|
||||
|
||||
fun reportsBy(users: Set<User>): List<Note> {
|
||||
return synchronized(reports) {
|
||||
reports.filter { it.author in users }
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun getOrCreateChannel(user: User): MutableSet<Note> {
|
||||
return messages[user] ?: run {
|
||||
|
Loading…
x
Reference in New Issue
Block a user