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

🐛 Bug Report: Topic Shows 0 Subscribers #7892

Closed
2 tasks done
ItzNotABug opened this issue Apr 1, 2024 · 8 comments · Fixed by #8271
Closed
2 tasks done

🐛 Bug Report: Topic Shows 0 Subscribers #7892

ItzNotABug opened this issue Apr 1, 2024 · 8 comments · Fixed by #8271
Assignees
Labels
bug Something isn't working product / messaging Fixes and upgrades for the Appwrite Messaging.

Comments

@ItzNotABug
Copy link
Contributor

👟 Reproduction steps

Pre-requisite: Assuming you have a few messaging targets [email, push, etc.] in a project.


  1. Go to Console > Select a Project
  2. Go to Messaging Dashboard
  3. Select Topics Tab & Create a Topic
  4. You are navigated to the Topic Dashboard, Click on "Add subscriber"
  5. Select the Targets to add as Subscribers
  6. Go Back to Topics Page
  7. You'll see the Subscriber count is 0

Screenshots

  1. Subscribers

topic-subscribers

  1. Topic Table

topics

👍 Expected behavior

Show correct subscribers count.

👎 Actual Behavior

Subscribers count is always 0.

🎲 Appwrite version

Version 1.5.x

💻 Operating system

MacOS

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@ItzNotABug ItzNotABug added the bug Something isn't working label Apr 1, 2024
@stnguyen90
Copy link
Contributor

@ItzNotABug, thanks for creating this issue! 🙏🏼 I can't seem to reproduce 🧐 I added 2 subscribers:

image

And the subscribers count shows 2:

image

Some questions:

  1. Which 1.5 version are you on?
  2. What's the JSON for the get topic api call? Mine is:
{
  "$id": "topic-1",
  "$createdAt": "2024-03-12T13:55:45.097+00:00",
  "$updatedAt": "2024-03-12T13:55:45.097+00:00",
  "name": "Topic 1",
  "emailTotal": 1,
  "smsTotal": 0,
  "pushTotal": 1,
  "subscribe": [
    "users"
  ]
}

@stnguyen90 stnguyen90 self-assigned this Apr 1, 2024
@stnguyen90 stnguyen90 added the product / messaging Fixes and upgrades for the Appwrite Messaging. label Apr 1, 2024
@ItzNotABug
Copy link
Contributor Author

ItzNotABug commented Apr 2, 2024

@stnguyen90, I tried by recreating a topic. The result was still the same.

Appwrite: 1.5.4
JSON for the get topic api call -

{
  "total":1,
  "topics":[
    {
      "$id":"general",
      "$createdAt":"2024-04-02T05:56:26.034+00:00",
      "$updatedAt":"2024-04-02T05:56:26.034+00:00",
      "name":"General",
      "emailTotal":0,
      "smsTotal":0,
      "pushTotal":0,
      "subscribe":[
        "users"
      ]
    }
  ]
}

@ItzNotABug
Copy link
Contributor Author

Update: I tried in an incognito tab on Chrome, seems to work fine now. It was probably the cache.
Although now there's a different issue, something with the state I guess. I'll file another issue for that.

Closing this one.

@ItzNotABug
Copy link
Contributor Author

Reopening this as I can again reproduce this on a 1.5.7, self-hosted instance.

@ItzNotABug ItzNotABug reopened this Jun 10, 2024
@ItzNotABug
Copy link
Contributor Author

ItzNotABug commented Jun 10, 2024

Updated specs -

Topic shows 0 -

topic-shows-no-subscribers

Topic has 2 subs -

topic-has-subcribers


JSON Responses -

  1. Topic Call
{
  "$id":"test",
  "$createdAt":"2024-06-10T08:06:29.493+00:00",
  "$updatedAt":"2024-06-10T08:06:29.493+00:00",
  "name":"Test Topic",
  "emailTotal":0,
  "smsTotal":0,
  "pushTotal":0,
  "subscribe":[
    "users"
  ]
}
  1. Subscribers Call
{
  "total":2,
  "subscribers":[
    {
      "$id":"6666b40f001e1d1d7bac",
      "$createdAt":"2024-06-10T08:06:39.727+00:00",
      "$updatedAt":"2024-06-10T08:06:39.727+00:00",
      "targetId":"6666b3e5e64f0eda3f00",
      "target":{
        "$id":"6666b3e5e64f0eda3f00",
        "$createdAt":"2024-06-10T08:05:58.191+00:00",
        "$updatedAt":"2024-06-10T08:05:58.191+00:00",
        "name":"Apple iPhone",
        "userId":"6666b3de7c95b8045713",
        "providerId":null,
        "providerType":"push",
        "identifier":"bbca71e6249223938d5c815fc793eb65247e5f57cbcf4b5913207ac00fc41257"
      },
      "userId":"6666b3de7c95b8045713",
      "userName":"",
      "topicId":"test",
      "providerType":"push"
    },
    {
      "$id":"6666b40f001e07efa34c",
      "$createdAt":"2024-06-10T08:06:39.722+00:00",
      "$updatedAt":"2024-06-10T08:06:39.722+00:00",
      "targetId":"6666b1bbe691424290b3",
      "target":{
        "$id":"6666b1bbe691424290b3",
        "$createdAt":"2024-06-10T07:56:44.161+00:00",
        "$updatedAt":"2024-06-10T07:56:44.161+00:00",
        "name":"Apple iPhone 15 Pro",
        "userId":"6666b1b760ab54a347dd",
        "providerId":null,
        "providerType":"push",
        "identifier":"8038bbdb6efb2eb8ad5d39aabc336a9d78eb8fe541ede49971aa4943461beab1c1d59f6936f91d34c31cf9db855e559f166e10909cbc8e400ea666c2a488b0fecc4c01a958e16e6a63d9452019f387f4"
      },
      "userId":"6666b1b760ab54a347dd",
      "userName":"",
      "topicId":"test",
      "providerType":"push"
    }
  ]
}

Table -

subscribers-table

@ItzNotABug
Copy link
Contributor Author

Update -
The issue lies in the migration script where no default is provided so it resorts to NULL which doesn't really perform an increment on the attribute.

Source -

'required' => $attribute['required'],

@ItzNotABug
Copy link
Contributor Author

ItzNotABug commented Jun 13, 2024

@stnguyen90, can I work on this?
I see that the config/collections.php includes the default values, just not the migration.

A quick fix like below suffices?

'default' => $attribute['default'] ?? null,

@stnguyen90
Copy link
Contributor

We also need to fix the topics collection for people already on 1.5.x. So, the V20.php migration would need to be updated to update the topics collection and set the default after the webhook one:

case 'webhooks':
// Create enabled attribute
try {
$this->createAttributeFromCollection($this->projectDB, $id, 'enabled');
} catch (Throwable $th) {
Console::warning("'enabled' from {$id}: {$th->getMessage()}");
}
// Create logs attribute
try {
$this->createAttributeFromCollection($this->projectDB, $id, 'logs');
} catch (Throwable $th) {
Console::warning("'logs' from {$id}: {$th->getMessage()}");
}
// Create attempts attribute
try {
$this->createAttributeFromCollection($this->projectDB, $id, 'attempts');
} catch (Throwable $th) {
Console::warning("'attempts' from {$id}: {$th->getMessage()}");
}
try {
$this->projectDB->purgeCachedCollection($id);
} catch (Throwable $th) {
Console::warning("Purge cache from {$id}: {$th->getMessage()}");
}
break;
}

@stnguyen90 stnguyen90 linked a pull request Jun 20, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / messaging Fixes and upgrades for the Appwrite Messaging.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants