Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thunderbird-slack-provider",
"version": "1.2.1",
"version": "1.2.2",
"private": true,
"scripts": {
"test": "jest",
Expand Down
4 changes: 2 additions & 2 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
return _watchedMutex;
}

let state = {

Check warning on line 25 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

'state' is never reassigned. Use 'const' instead

Check warning on line 25 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

'state' is never reassigned. Use 'const' instead

Check warning on line 25 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

'state' is never reassigned. Use 'const' instead
token: null,
slackSpaceId: null,
unreadChannels: new Set(),
Expand Down Expand Up @@ -104,8 +104,8 @@
*/
function registerChatProtocol() {
if (!messenger.chat) {
// messenger.chat is available in Thunderbird 128+ when the "chat" permission
// is granted. Gracefully degrade on older builds.
// messenger.chat may be unavailable depending on Thunderbird build/API
// support. Gracefully degrade when the API is absent.
console.warn("messenger.chat is not available in this version of Thunderbird.");
return;
}
Expand Down Expand Up @@ -252,12 +252,12 @@
});

async function pollUnread() {
if (!state.token) return;

Check warning on line 255 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Expected { after 'if' condition

Check warning on line 255 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition

Check warning on line 255 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition
try {
const channels = await fetchAllChannels();
const unread = new Set();
for (const ch of channels) {
if (ch.is_member && ch.unread_count > 0) unread.add(ch.id);

Check warning on line 260 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Expected { after 'if' condition

Check warning on line 260 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition

Check warning on line 260 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition
}
state.unreadChannels = unread;

Expand All @@ -282,7 +282,7 @@

async function slackPost(method, params = {}, token = null) {
const useToken = token || state.token;
if (!useToken) throw new Error("No Slack token configured.");

Check warning on line 285 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Expected { after 'if' condition

Check warning on line 285 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition

Check warning on line 285 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition
const resp = await fetch(`${SLACK_API}/${method}`, {
method: "POST",
headers: {
Expand All @@ -292,7 +292,7 @@
body: JSON.stringify(params),
});
const json = await resp.json();
if (!json.ok) throw new Error(json.error || "Slack API error");

Check warning on line 295 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Expected { after 'if' condition

Check warning on line 295 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition

Check warning on line 295 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition
return json;
}

Expand All @@ -314,7 +314,7 @@
limit: state.rateLimitedMode ? 20 : 200,
exclude_archived: true,
};
if (cursor) params.cursor = cursor;

Check warning on line 317 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Expected { after 'if' condition

Check warning on line 317 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition

Check warning on line 317 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Expected { after 'if' condition
const data = await slackPost("conversations.list", params, token);
channels.push(...(data.channels || []));
cursor = data.response_metadata?.next_cursor || undefined;
Expand All @@ -325,7 +325,7 @@
// ---------------------------------------------------------------------------
// Message handler (UI ↔ background)
// ---------------------------------------------------------------------------
messenger.runtime.onMessage.addListener(async (msg) => {

Check warning on line 328 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Async arrow function has a complexity of 28. Maximum allowed is 15

Check warning on line 328 in src/background.js

View workflow job for this annotation

GitHub Actions / Test (unit, integration, e2e)

Async arrow function has too many lines (128). Maximum allowed is 80

Check warning on line 328 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Async arrow function has a complexity of 28. Maximum allowed is 15

Check warning on line 328 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Async arrow function has too many lines (128). Maximum allowed is 80

Check warning on line 328 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Async arrow function has a complexity of 28. Maximum allowed is 15

Check warning on line 328 in src/background.js

View workflow job for this annotation

GitHub Actions / SAST – ESLint (security + code smells)

Async arrow function has too many lines (128). Maximum allowed is 80
try {
switch (msg.type) {
// ---- Workspace ---------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Thunderbird Slack Provider",
"version": "1.2.1",
"version": "1.2.2",
"description": "Read and send Slack channel messages directly from Thunderbird.",
"author": "thunderbird-slack-provider contributors",
"icons": {
Expand All @@ -15,7 +15,6 @@
"permissions": [
"storage",
"alarms",
"chat",
"https://slack.com/api/*",
"https://files.slack.com/*",
"https://avatars.slack-edge.com/*"
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/manifest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const fs = require("fs");
const path = require("path");

describe("manifest chat protocol declaration", () => {
test("declares Slack chat protocol with iconURL so it appears in New Chat", () => {
test("declares Slack chat protocol with iconURL and does not require chat permission", () => {
const manifestPath = path.resolve(__dirname, "../../src/manifest.json");
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));

expect(manifest.permissions).not.toContain("chat");
expect(Array.isArray(manifest.chat_protocols)).toBe(true);
expect(manifest.chat_protocols).toEqual(
expect.arrayContaining([
Expand Down
Loading