Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add report queue #1360

Merged
merged 28 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f4fe8c3
Starting to work on registration applications.
dessalines Jan 30, 2024
35d4132
Remove ImmutableList and add stability config file (#1342)
MV-GH Feb 5, 2024
42d37e8
Adding admin / mod view votes. (#1331)
dessalines Feb 5, 2024
fb11307
Temp workaround for compose-settings height bug. (#1345)
dessalines Feb 5, 2024
d71f554
Swipe post/comment to upvote/downvote/reply/save (#1327)
Snow4DV Feb 5, 2024
455d1f9
Almost finished viewmodel.
dessalines Feb 5, 2024
6dfc40c
Merge branch 'main' into registration_apps
dessalines Feb 6, 2024
974c6a0
A few more additions.
dessalines Feb 7, 2024
592701b
Finishing up registration applications.
dessalines Feb 7, 2024
478c7f9
Adding a locally generated changelog.
dessalines Feb 8, 2024
f074a93
Removing 27 schema
dessalines Feb 8, 2024
9708b5d
Removing 27 schema 2
dessalines Feb 8, 2024
52d8b6a
Merge branches 'registration_apps' and 'changelog_local' into add_rep…
dessalines Feb 8, 2024
3e2aee0
Adding the admin / mod report queue.
dessalines Feb 9, 2024
247b6f9
Moving changelog fetching to viewModel.
dessalines Feb 9, 2024
bbb6b1b
Merge branch 'changelog_local' into registration_apps
dessalines Feb 9, 2024
04629f1
Persisting admin and mod status to DB.
dessalines Feb 9, 2024
9b65730
Fixing format.
dessalines Feb 9, 2024
f37266c
Merge remote-tracking branch 'origin/main' into registration_apps
dessalines Feb 9, 2024
249cc06
Removing weird changes.
dessalines Feb 9, 2024
1378e76
Merge branch 'registration_apps' into add_report_queue
dessalines Feb 9, 2024
631229d
Missed formatting.
dessalines Feb 10, 2024
09697c0
Merge branch 'main' into add_report_queue
dessalines Feb 12, 2024
906ecea
Forgot to remove unused block.
dessalines Feb 12, 2024
12b7621
Merge remote-tracking branch 'origin/main' into add_report_queue
dessalines Feb 12, 2024
5055832
Fixing missing fullBody.
dessalines Feb 12, 2024
c04bd7e
Addressing PR comments.
dessalines Feb 13, 2024
d549825
Merge branch 'main' into add_report_queue
dessalines Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/JerboaAppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class JerboaAppState(
navController.navigate(Route.COMMENT_REPLY)
}

fun toComment(id: CommunityId) {
fun toComment(id: CommentId) {
navController.navigate(Route.CommentArgs.makeRoute(id = "$id"))
}

Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import com.jerboa.ui.components.remove.comment.CommentRemoveActivity
import com.jerboa.ui.components.remove.post.PostRemoveActivity
import com.jerboa.ui.components.report.comment.CreateCommentReportActivity
import com.jerboa.ui.components.report.post.CreatePostReportActivity
import com.jerboa.ui.components.reports.ReportsActivity
import com.jerboa.ui.components.settings.SettingsActivity
import com.jerboa.ui.components.settings.about.AboutActivity
import com.jerboa.ui.components.settings.account.AccountSettingsActivity
Expand Down Expand Up @@ -450,6 +451,29 @@ class MainActivity : AppCompatActivity() {
)
}

composable(
route = Route.REGISTRATION_APPLICATIONS,
) {
RegistrationApplicationsActivity(
appState = appState,
accountViewModel = accountViewModel,
siteViewModel = siteViewModel,
drawerState = drawerState,
)
}

composable(
route = Route.REPORTS,
) {
ReportsActivity(
appState = appState,
accountViewModel = accountViewModel,
siteViewModel = siteViewModel,
drawerState = drawerState,
blurNSFW = appSettings.blurNSFW.toEnum(),
)
}

composable(
route = Route.POST,
deepLinks =
Expand Down
51 changes: 51 additions & 0 deletions app/src/main/java/com/jerboa/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,57 @@ fun findAndUpdateApplication(
}
}

fun findAndUpdatePostReport(
reports: List<PostReportView>,
updatedReport: PostReportView,
): List<PostReportView> {
val foundIndex =
reports.indexOfFirst {
it.post_report.id == updatedReport.post_report.id
}
return if (foundIndex != -1) {
val mutable = reports.toMutableList()
mutable[foundIndex] = updatedReport
mutable.toList()
} else {
reports
}
}

fun findAndUpdateCommentReport(
reports: List<CommentReportView>,
updatedReport: CommentReportView,
): List<CommentReportView> {
val foundIndex =
reports.indexOfFirst {
it.comment_report.id == updatedReport.comment_report.id
}
return if (foundIndex != -1) {
val mutable = reports.toMutableList()
mutable[foundIndex] = updatedReport
mutable.toList()
} else {
reports
}
}

fun findAndUpdatePrivateMessageReport(
reports: List<PrivateMessageReportView>,
updatedReport: PrivateMessageReportView,
): List<PrivateMessageReportView> {
val foundIndex =
reports.indexOfFirst {
it.private_message_report.id == updatedReport.private_message_report.id
}
return if (foundIndex != -1) {
val mutable = reports.toMutableList()
mutable[foundIndex] = updatedReport
mutable.toList()
} else {
reports
}
}

fun showBlockPersonToast(
blockPersonRes: ApiState<BlockPersonResponse>,
ctx: Context,
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/jerboa/datatypes/Others.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,12 @@ data class PostFeatureData(
val type: PostFeatureType,
val featured: Boolean,
)

/**
* Says which type of users can view which bottom app bar tabs.
*/
enum class UserViewType {
Normal,
AdminOnly,
AdminOrMod,
}
95 changes: 95 additions & 0 deletions app/src/main/java/com/jerboa/datatypes/SampleData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import it.vercruysse.lemmyapi.v0x19.datatypes.Comment
import it.vercruysse.lemmyapi.v0x19.datatypes.CommentAggregates
import it.vercruysse.lemmyapi.v0x19.datatypes.CommentReply
import it.vercruysse.lemmyapi.v0x19.datatypes.CommentReplyView
import it.vercruysse.lemmyapi.v0x19.datatypes.CommentReport
import it.vercruysse.lemmyapi.v0x19.datatypes.CommentReportView
import it.vercruysse.lemmyapi.v0x19.datatypes.CommentView
import it.vercruysse.lemmyapi.v0x19.datatypes.Community
import it.vercruysse.lemmyapi.v0x19.datatypes.CommunityAggregates
Expand All @@ -23,8 +25,12 @@ import it.vercruysse.lemmyapi.v0x19.datatypes.PersonMentionView
import it.vercruysse.lemmyapi.v0x19.datatypes.PersonView
import it.vercruysse.lemmyapi.v0x19.datatypes.Post
import it.vercruysse.lemmyapi.v0x19.datatypes.PostAggregates
import it.vercruysse.lemmyapi.v0x19.datatypes.PostReport
import it.vercruysse.lemmyapi.v0x19.datatypes.PostReportView
import it.vercruysse.lemmyapi.v0x19.datatypes.PostView
import it.vercruysse.lemmyapi.v0x19.datatypes.PrivateMessage
import it.vercruysse.lemmyapi.v0x19.datatypes.PrivateMessageReport
import it.vercruysse.lemmyapi.v0x19.datatypes.PrivateMessageReportView
import it.vercruysse.lemmyapi.v0x19.datatypes.PrivateMessageView
import it.vercruysse.lemmyapi.v0x19.datatypes.RegistrationApplication
import it.vercruysse.lemmyapi.v0x19.datatypes.RegistrationApplicationView
Expand Down Expand Up @@ -195,6 +201,25 @@ val samplePerson2 =
instance_id = 0,
)

val samplePerson3 =
Person(
id = 33478,
name = "witch_power",
display_name = null,
banned = false,
published = "2021-08-08T01:47:44.437708",
updated = "2021-10-11T07:14:53.548707",
actor_id = "https://lemmy.ml/u/witch_power",
bio = null,
local = true,
banner = null,
deleted = false,
matrix_user_id = null,
bot_account = false,
ban_expires = null,
instance_id = 0,
)

val sampleLocalUser = LocalUser(
id = 24,
person_id = 82,
Expand Down Expand Up @@ -692,3 +717,73 @@ val sampleDeniedRegistrationApplicationView =
creator_local_user = sampleLocalUser,
admin = samplePerson2,
)

val samplePostReport =
PostReport(
creator_id = 28,
id = 89,
original_post_name = samplePost.name,
post_id = samplePost.id,
published = samplePost.published,
reason = "This post is *peak* **cringe**",
resolved = true,
resolver_id = samplePerson3.id,
)

val samplePostReportView =
PostReportView(
post_creator = samplePerson,
creator = samplePerson2,
resolver = samplePerson3,
post = samplePost,
post_report = samplePostReport,
community = sampleCommunity,
counts = samplePostAggregates,
creator_banned_from_community = false,
)

val sampleCommentReport =
CommentReport(
creator_id = 28,
id = 89,
original_comment_text = sampleComment.content,
comment_id = sampleComment.id,
published = sampleComment.published,
reason = "This is a bad comment, remove it plz.",
resolved = true,
resolver_id = samplePerson3.id,
)

val sampleCommentReportView =
CommentReportView(
comment_creator = samplePerson,
creator = samplePerson2,
resolver = samplePerson3,
post = samplePost,
comment = sampleComment,
comment_report = sampleCommentReport,
community = sampleCommunity,
counts = sampleCommentAggregates,
creator_banned_from_community = false,
)

val samplePrivateMessageReport =
PrivateMessageReport(
creator_id = 28,
id = 89,
original_pm_text = samplePrivateMessage.content,
private_message_id = samplePrivateMessage.id,
published = sampleComment.published,
reason = "This PM is from a spammer",
resolved = true,
resolver_id = samplePerson3.id,
)

val samplePrivateMessageReportView =
PrivateMessageReportView(
private_message_report = samplePrivateMessageReport,
private_message = samplePrivateMessage,
private_message_creator = samplePerson,
creator = samplePerson2,
resolver = samplePerson3,
)
11 changes: 11 additions & 0 deletions app/src/main/java/com/jerboa/db/entity/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.jerboa.db.entity
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.jerboa.datatypes.UserViewType
import com.jerboa.feat.AccountVerificationState

@Entity
Expand Down Expand Up @@ -53,3 +54,13 @@ fun Account.isAnon(): Boolean {
fun Account.isReady(): Boolean {
return this.verificationState == AccountVerificationState.CHECKS_COMPLETE.ordinal
}

fun Account.userViewType(): UserViewType {
return if (isAdmin) {
UserViewType.AdminOnly
} else if (isMod) {
UserViewType.AdminOrMod
} else {
UserViewType.Normal
}
}
Loading