Browse Source

finish unlisted feature, make hub err into warning

push-params
Evan Feenstra 5 years ago
parent
commit
bac904edd8
  1. 37
      api/controllers/chatTribes.ts
  2. 3
      api/controllers/chats.ts
  3. 2
      api/hub.ts
  4. 8
      api/models/ts/chat.ts
  5. 40
      dist/api/controllers/chatTribes.js
  6. 2
      dist/api/controllers/chatTribes.js.map
  7. 4
      dist/api/controllers/chats.js
  8. 2
      dist/api/controllers/chats.js.map
  9. 2
      dist/api/hub.js
  10. 2
      dist/api/hub.js.map
  11. 5
      dist/api/models/ts/chat.js
  12. 2
      dist/api/models/ts/chat.js.map

37
api/controllers/chatTribes.ts

@ -96,7 +96,6 @@ export async function joinTribe(req, res){
export async function editTribe(req, res) {
const {
name,
is_listed,
price_per_message,
price_to_join,
escrow_amount,
@ -118,25 +117,23 @@ export async function editTribe(req, res) {
const owner = await models.Contact.findOne({ where: { isOwner: true } })
let okToUpdate = true
if(is_listed) {
try{
await tribes.edit({
uuid: chat.uuid,
name: name,
host: chat.host,
price_per_message: price_per_message||0,
price_to_join: price_to_join||0,
escrow_amount: escrow_amount||0,
escrow_millis: escrow_millis||0,
description,
tags,
img,
owner_alias: owner.alias,
unlisted,
})
} catch(e) {
okToUpdate = false
}
try{
await tribes.edit({
uuid: chat.uuid,
name: name,
host: chat.host,
price_per_message: price_per_message||0,
price_to_join: price_to_join||0,
escrow_amount: escrow_amount||0,
escrow_millis: escrow_millis||0,
description,
tags,
img,
owner_alias: owner.alias,
unlisted,
})
} catch(e) {
okToUpdate = false
}
if(okToUpdate) {

3
api/controllers/chats.ts

@ -137,7 +137,6 @@ export async function createGroupChat(req, res) {
const {
name,
is_tribe,
is_listed,
price_per_message,
price_to_join,
escrow_amount,
@ -167,7 +166,7 @@ export async function createGroupChat(req, res) {
let okToCreate = true
if(is_tribe){
chatParams = await createTribeChatParams(owner, contact_ids, name, img, price_per_message, price_to_join, escrow_amount, escrow_millis, unlisted)
if(is_listed && chatParams.uuid){
if(chatParams.uuid){
// publish to tribe server
try {
await tribes.declare({

2
api/hub.ts

@ -99,7 +99,7 @@ const sendHubCall = (params) => {
headers: { 'Content-Type': 'application/json' }
})
.catch(error => {
console.log('[hub error]', error)
console.log('[hub warning]: cannot reach hub',)
})
}

8
api/models/ts/chat.ts

@ -66,8 +66,12 @@ export default class Chat extends Model<Chat> {
@Column(DataType.BIGINT)
escrowMillis: number
@Column
unlisted: boolean // dont show on tribes list
@Column({ // dont show on tribes list
type: DataType.BOOLEAN,
defaultValue: false,
// allowNull: false
})
unlisted: boolean
@Column
private: boolean // joining requires approval of admin

40
dist/api/controllers/chatTribes.js

@ -100,7 +100,7 @@ function joinTribe(req, res) {
exports.joinTribe = joinTribe;
function editTribe(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const { name, is_listed, price_per_message, price_to_join, escrow_amount, escrow_millis, img, description, tags, unlisted, } = req.body;
const { name, price_per_message, price_to_join, escrow_amount, escrow_millis, img, description, tags, unlisted, } = req.body;
const { id } = req.params;
if (!id)
return res_1.failure(res, 'group id is required');
@ -110,26 +110,24 @@ function editTribe(req, res) {
}
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
let okToUpdate = true;
if (is_listed) {
try {
yield tribes.edit({
uuid: chat.uuid,
name: name,
host: chat.host,
price_per_message: price_per_message || 0,
price_to_join: price_to_join || 0,
escrow_amount: escrow_amount || 0,
escrow_millis: escrow_millis || 0,
description,
tags,
img,
owner_alias: owner.alias,
unlisted,
});
}
catch (e) {
okToUpdate = false;
}
try {
yield tribes.edit({
uuid: chat.uuid,
name: name,
host: chat.host,
price_per_message: price_per_message || 0,
price_to_join: price_to_join || 0,
escrow_amount: escrow_amount || 0,
escrow_millis: escrow_millis || 0,
description,
tags,
img,
owner_alias: owner.alias,
unlisted,
});
}
catch (e) {
okToUpdate = false;
}
if (okToUpdate) {
yield chat.update({

2
dist/api/controllers/chatTribes.js.map

File diff suppressed because one or more lines are too long

4
dist/api/controllers/chats.js

@ -144,7 +144,7 @@ exports.mute = mute;
// or can u add contacts as members?
function createGroupChat(req, res) {
return __awaiter(this, void 0, void 0, function* () {
const { name, is_tribe, is_listed, price_per_message, price_to_join, escrow_amount, escrow_millis, img, description, tags, unlisted, } = req.body;
const { name, is_tribe, price_per_message, price_to_join, escrow_amount, escrow_millis, img, description, tags, unlisted, } = req.body;
const contact_ids = req.body.contact_ids || [];
const members = {}; //{pubkey:{key,alias}, ...}
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
@ -162,7 +162,7 @@ function createGroupChat(req, res) {
let okToCreate = true;
if (is_tribe) {
chatParams = yield chatTribes_1.createTribeChatParams(owner, contact_ids, name, img, price_per_message, price_to_join, escrow_amount, escrow_millis, unlisted);
if (is_listed && chatParams.uuid) {
if (chatParams.uuid) {
// publish to tribe server
try {
yield tribes.declare({

2
dist/api/controllers/chats.js.map

File diff suppressed because one or more lines are too long

2
dist/api/hub.js

@ -94,7 +94,7 @@ const sendHubCall = (params) => {
headers: { 'Content-Type': 'application/json' }
})
.catch(error => {
console.log('[hub error]', error);
console.log('[hub warning]: cannot reach hub');
});
};
exports.sendHubCall = sendHubCall;

2
dist/api/hub.js.map

File diff suppressed because one or more lines are too long

5
dist/api/models/ts/chat.js

@ -94,7 +94,10 @@ __decorate([
__metadata("design:type", Number)
], Chat.prototype, "escrowMillis", void 0);
__decorate([
sequelize_typescript_1.Column,
sequelize_typescript_1.Column({
type: sequelize_typescript_1.DataType.BOOLEAN,
defaultValue: false,
}),
__metadata("design:type", Boolean)
], Chat.prototype, "unlisted", void 0);
__decorate([

2
dist/api/models/ts/chat.js.map

@ -1 +1 @@
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../api/models/ts/chat.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAsE;AAGtE,IAAqB,IAAI,GAAzB,MAAqB,IAAK,SAAQ,4BAAW;CAiF5C,CAAA;AAzEC;IANC,6BAAM,CAAC;QACN,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,UAAU,EAAE,IAAI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