Skip to content

Commit

Permalink
Add report queue (#1360)
Browse files Browse the repository at this point in the history
* Starting to work on registration applications.

* Remove ImmutableList and add stability config file (#1342)

* Adding admin / mod view votes. (#1331)

* Starting to work on admin_view_votes, needs API added yet.

* Finished up adding admin view votes.

* Fix package name.

* Upping lemmy-api version.

* Adding a moderation subfield to post and comment action dropdowns.

* Adding feature flag check.

* Addressing PR comments.

- Moving padding up to Box.
- Using alternate feature flag method.

* Temp workaround for compose-settings height bug. (#1345)

- See alorma/Compose-Settings#203
- Fixes #1338

* Swipe post/comment to upvote/downvote/reply/save (#1327)

* SwipeToAction composable

* Swipe to downvote/upvote feature implemented with preset-based customization

* Fix kotlin format

* fix string resource

* Do not use SwipeToAction when it is disabled

* Improve scrolling experience

* Increase color shift animation speed

* Improve ranges

* new preset: only votes

* fix deltas & rename resources

* SwipeToAction implemented correctly, SwipeToDismiss replaced with SwipeToDismissBox, fixed swipe ranges

* Kotlin format

* use ordinal of enum in AppDB instead of int

* Fixed behaviour when downvotes disables/when not logged in

* Fix formatting

* Remove default param for enableDownVotes in SwipeToAction

* Fix colors for swipe actions

* Fixed lambda caching in rememberSwipeActionState

* Format kotlin

---------

Co-authored-by: Dessalines <[email protected]>

* Almost finished viewmodel.

* A few more additions.

* Finishing up registration applications.

* Adding a locally generated changelog.

- Adds a last_version_code_viewed, that gets updated in the DB,
  and compared against the current version to show the changelog.
  This means we never have to manually update that column again.
- Add a generate_changelog.sh script that uses git-cliff. It copies
  the changelog into code assets, which can be done before the release.
- Fixes #1272

* Removing 27 schema

* Removing 27 schema 2

* Adding the admin / mod report queue.

* Moving changelog fetching to viewModel.

* Persisting admin and mod status to DB.

* Fixing format.

* Removing weird changes.

* Missed formatting.

* Forgot to remove unused block.

* Fixing missing fullBody.

* Addressing PR comments.

---------

Co-authored-by: Maarten Vercruysse <[email protected]>
Co-authored-by: Mikhail Loginov <[email protected]>
  • Loading branch information
3 people authored Feb 14, 2024
1 parent 325814d commit 9ee80b4
Show file tree
Hide file tree
Showing 20 changed files with 1,761 additions and 20 deletions.
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 @@ -451,6 +452,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 @@ -980,6 +980,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 @@ -694,3 +719,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

0 comments on commit 9ee80b4

Please sign in to comment.