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 option to mark status as sensitive #17

Merged
merged 1 commit into from
Dec 28, 2022
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
22 changes: 22 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
api-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
# This is a path to the cache file, using the above cache path
cache-file: ${{ github.workspace }}/mastofeedbot/cache.json

simple-dry-run:
runs-on: ubuntu-latest
steps:
Expand All @@ -72,3 +73,24 @@ jobs:
api-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
# This is a path to the cache file, using the above cache path
cache-file: ${{ github.workspace }}/mastofeedbot/cache.json

simple-sensitive:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
- name: Run action
uses: './'
with:
# This is the RSS feed you want to publish
rss-feed: 'https://githubraw.com/joschi/mastofeedbot/main/tests/simple.xml'
# Visibility of the posted status (public | unlisted | private | direct)
status-visibility: unlisted
# Mark Mastodon status as sensitive content
sensitive: true
# This is your instance address
api-endpoint: https://social.dev-wiki.de/
# This is the secret you created earlier
api-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
# This is a path to the cache file, using the above cache path
cache-file: ${{ github.workspace }}/mastofeedbot/cache.json
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
rss-feed: https://www.githubstatus.com/history.rss
# Visibility of the posted status (public | unlisted | private | direct)
status-visibility: public
# Mark Mastodon status as sensitive content
sensitive: false
# This is your instance address
api-endpoint: https://mastodon.social
# This is the secret you created earlier
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: 'Only fetch RSS feed and update cache but skip posting to Mastodon.'
required: false
default: 'false'
sensitive:
description: 'Mark Mastodon status as sensitive content.'
required: false
default: 'false'
cache-file:
description: 'Cache file'
required: true
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function writeCache(cacheFile: string, cacheLimit: number, cache: string[]

async function postItems(
apiEndpoint: string, apiToken: string, rss: FeedEntry[],
visibility: StatusVisibility, dryRun: boolean, cache: string[]) {
visibility: StatusVisibility, dryRun: boolean, sensitive: boolean, cache: string[]) {
if (dryRun) {
// Add new items to cache
for (const item of rss) {
Expand Down Expand Up @@ -69,6 +69,7 @@ async function postItems(
const res = await masto.statuses.create({
status: `${item.title} ${item.link}`,
visibility,
sensitive
}, hash);
core.debug(`Response:\n\n${JSON.stringify(res, null, 2)}`);

Expand Down Expand Up @@ -130,6 +131,8 @@ export async function main(): Promise<void> {
core.debug(`statusVisibility: ${statusVisibility}`);
const dryRun: boolean = core.getBooleanInput('dry-run');
core.debug(`dryRun: ${dryRun}`);
const sensitive: boolean = core.getBooleanInput('sensitive');
core.debug(`sensitive: ${sensitive}`);

// get the rss feed
let rss = await getRss(rssFeed);
Expand All @@ -141,7 +144,7 @@ export async function main(): Promise<void> {
rss = await filterCachedItems(<FeedEntry[]>rss, cache);

// post the new items
await postItems(apiEndpoint, apiToken, <FeedEntry[]>rss, statusVisibility, dryRun, cache);
await postItems(apiEndpoint, apiToken, <FeedEntry[]>rss, statusVisibility, dryRun, sensitive, cache);

// write the cache
await writeCache(cacheFile, cacheLimit, cache);
Expand Down