Skip to content

Commit

Permalink
Merge pull request #321 from mvdicarlo/develop
Browse files Browse the repository at this point in the history
v3.1.41
  • Loading branch information
mvdicarlo authored Apr 2, 2024
2 parents f1ba73f + fe429db commit af71e17
Show file tree
Hide file tree
Showing 27 changed files with 1,226 additions and 66 deletions.
4 changes: 3 additions & 1 deletion commons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export * from './interfaces/websites/pixelfed/pixelfed.file.options.interface';
export * from './interfaces/websites/bluesky/bluesky.account.interface';
export * from './interfaces/websites/bluesky/bluesky.file.options.interface';
export * from './interfaces/websites/bluesky/bluesky.notification.options.interface';
export * from './interfaces/websites/twitter/twitter.file.options.interface';
export * from './interfaces/websites/twitter/twitter.account.interface';

// Models/Entities
export * from './models/default-options.entity';
Expand All @@ -104,4 +106,4 @@ import * as WebsiteOptions from './websites/websites';
export { WebsiteOptions };

// Doesn't really fit :P
export * from './websites/megalodon/megalodon.instancesettings';
export * from './websites/megalodon/megalodon.instancesettings';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface TwitterAccountData {
key: string;
secret: string;
user_id: number;
screen_name: string;
oauth_token: string;
oauth_token_secret: string;
}
18 changes: 18 additions & 0 deletions commons/src/websites/twitter/twitter.file.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Expose } from 'class-transformer';
import { IsString } from 'class-validator';
import { DefaultFileOptions } from '../../interfaces/submission/default-options.interface';
import { TwitterFileOptions } from '../../interfaces/websites/twitter/twitter.file.options.interface';
import { DefaultFileOptionsEntity } from '../../models/default-file-options.entity';

export class TwitterFileOptionsEntity
extends DefaultFileOptionsEntity
implements TwitterFileOptions
{
@Expose()
@IsString()
contentBlur?: 'other' | 'graphic_violence' | 'adult_content';

constructor(entity?: Partial<TwitterFileOptions>) {
super(entity as DefaultFileOptions);
}
}
7 changes: 7 additions & 0 deletions commons/src/websites/twitter/twitter.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DefaultOptionsEntity } from '../../models/default-options.entity';
import { TwitterFileOptionsEntity } from './twitter.file.options';

export class Twitter {
static readonly FileOptions = TwitterFileOptionsEntity;
static readonly NotificationOptions = DefaultOptionsEntity;
}
1 change: 1 addition & 0 deletions commons/src/websites/websites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export * from './weasyl/weasyl.options';
export * from './itaku/itaku.options';
export * from './pixelfed/pixelfed.options';
export * from './bluesky/bluesky.options';
export * from './twitter/twitter.options';
60 changes: 58 additions & 2 deletions electron-app/package-lock.json

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

3 changes: 2 additions & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb-plus",
"version": "3.1.40",
"version": "3.1.41",
"description": "(ClientServer) PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly.",
"main": "dist/main.js",
"author": "Michael DiCarlo",
Expand Down Expand Up @@ -78,6 +78,7 @@
"set-cookie-parser": "^2.4.5",
"shortid": "^2.2.16",
"turndown": "^5.0.3",
"twitter-lite": "^1.1.0",
"uuid": "^3.3.3",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^4.5.5"
Expand Down
21 changes: 18 additions & 3 deletions electron-app/src/app/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable: no-console no-var-requires */
import { app } from 'electron';
import { app, dialog } from 'electron';
import { Settings } from 'postybirb-commons';
const fs = require('fs-extra');
const path = require('path');
Expand All @@ -9,8 +9,7 @@ const util = require('./utils');

const settingsPath = path.join(global.BASE_DIRECTORY, 'data', 'settings.json');
fs.ensureFileSync(settingsPath);
const adapter = new FileSync(settingsPath);
const settings = low(adapter);
const settings = init();
const settingDefaults: Settings = {
advertise: true,
emptyQueueOnFailedPost: true,
Expand All @@ -34,3 +33,19 @@ if (!settings.getState().useHardwareAcceleration || util.isLinux()) {
}

global.settingsDB = settings;

function init() {
try {
const adapter = new FileSync(settingsPath);
return low(adapter);
} catch (e) {
console.error('Error initializing settings database', e);
fs.removeSync(settingsPath);
dialog.showErrorBox(
'Settings were corrupted',
'Settings could not be loaded and had to be reset.',
);
const adapter = new FileSync(settingsPath);
return low(adapter);
}
}
Loading

0 comments on commit af71e17

Please sign in to comment.