Skip to content

Conversation

@tobiasKaminsky
Copy link
Member

No description provided.

fun getShareFromNote(
@Query("path") path: String,
@Query("shared_with_me") sharedWithMe: Boolean = true
@Query("shared_with_me") sharedWithMe: Boolean = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web calls

format=json
path=%2FNotes%2FSamples%2FFormatting.md
shared_with_me=true

So I am not sure if this is correct to be changed


if (share.getSharedWithDisplayName() != null) {
AvatarLoader.INSTANCE.load(context, binding.icon, account, share.getSharedWithDisplayName());
AvatarLoader.INSTANCE.load(context, binding.icon, account, share.getShareWith());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Than the if-clause needs to be updated as well

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following string will be used to fetch avatar. username is expected value.

url + "/index.php/avatar/" + Uri.encode(username) + "/64"

When getSharedWithDisplayName(), getShareWith() these two returning different values?

Image

note.title +
notesSuffix
}
return StringConstants.PATH + notesPath + StringConstants.PATH + note.category + StringConstants.PATH + note.title + notesSuffix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail for notes not in a category I guess because it woudl add a StringConstants.PATH + StringConstants.PATH no?

@alperozturk96
Copy link
Collaborator

@tobiasKaminsky

What issue or bug does this PR fix? What should we test, and how should we test it? Could you share steps to reproduce the issue?

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
fun getShareFromNote(
@Query("path") path: String,
@Query("shared_with_me") sharedWithMe: Boolean = true
@Query("shared_with_me") sharedWithMe: Boolean = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default is true in current master but expected value is false then? And in where exactly this didn't set to actual value.


if (share.getSharedWithDisplayName() != null) {
AvatarLoader.INSTANCE.load(context, binding.icon, account, share.getSharedWithDisplayName());
AvatarLoader.INSTANCE.load(context, binding.icon, account, share.getShareWith());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following string will be used to fetch avatar. username is expected value.

url + "/index.php/avatar/" + Uri.encode(username) + "/64"

When getSharedWithDisplayName(), getShareWith() these two returning different values?

Image

}

fun getShareFromNote(note: Note): List<OCShare>? {
fun getShareFromNote(note: Note): List<OCShare> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need mutable list conversion and we can clearify variable names. Could you please change with following code?

fun getShareFromNote(note: Note): List<OCShare> {
  val sharesWithMe = fetchShares(note, sharedWithMe = true)
  val sharesWithOthers = fetchShares(note, sharedWithMe = false)
  return sharesWithOthers + sharesWithMe
}

private fun fetchShares(note: Note, sharedWithMe: Boolean): List<OCShare> {
  val api = apiProvider.getShareAPI(applicationContext, account)
  val path = getNotePath(note) ?: return emptyList()
  val call = api.getShareFromNote(path, sharedWithMe)
  val response = call.execute()

  return try {
    if (response.isSuccessful) {
      val body = response.body()
      Log_OC.d(tag, "Response successful: $body")
      body?.ocs?.data?.toOCShareList() ?: emptyList()
    } else {
      val errorBody = response.errorBody()?.string()
      Log_OC.d(tag, "Response failed: $errorBody")
      emptyList()
    }
  } catch (e: Exception) {
    Log_OC.d(tag, "Exception while getting share from note: ", e)
    emptyList()
  }
}

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/2974.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants